function login()
 {
     require 'Conn/Redirect.php';
     $redirect = new Redirect();
     if (isset($_POST["name"]) && isset($_POST["pwd"])) {
         $name = $_POST["name"];
         $pwd = md5($_POST["pwd"]);
         require_once 'Conn/Mysql.php';
         $mysql = new Mysql();
         $mysql->query("select * from users where name ='{$name}';");
         $row = $mysql->get_object();
         if (isset($row)) {
             if ($row->pwd == $pwd) {
                 session_start();
                 $_SESSION['user'] = $name;
                 $redirect->go('index.php');
             } else {
                 $error = "密码错误!";
                 $redirect->go('index.php?page=login');
             }
         } else {
             $error = "用户名不存在!";
             $redirect->go('index.php?page=login');
         }
     } else {
         $error = "用户名或密码不能为空!";
         $redirect->go('index.php?page=login');
     }
 }
Exemple #2
0
function getSocieteDeNomEtDeVille($nom, $ville)
{
    //echo "SELECT * FROM `societe` WHERE nom='".$nom."' AND ville='".$ville."'";
    return Mysql::get_object("SELECT * FROM `societe` WHERE nom='" . $nom . "' AND ville='" . $ville . "'");
}
Exemple #3
0
 /**
  * Renvoie un objet depuis sa table et son id
  * @param string $table
  * @param int $id
  * @return object
  */
 static function get_object_from_id($table, $id)
 {
     return Mysql::get_object("SELECT * FROM `%s` WHERE id = '%d'", $table, $id);
 }