如何修复PHP中的用户登录功能?

时间:2019-04-21 13:40:33

标签: php symfony

我正在设置我的客户端控制器(案例:连接并连接),select与我的主键示例select($ key)一起使用  但是带有属性的select不会是示例($ login,$ password) 即使输入正确的登录名和密码,我也将重定向到

的登录表单

我尝试更改sql请求和表单输入


model.php的一部分


 public function select($cle_primaire) {
   ** $sql = "SELECT * from ".static::$table." WHERE ".static::$primary."=:cle_primaire";**
    $req_prep = Model::$pdo->prepare($sql);
    $req_prep->bindParam(":cle_primaire", $cle_primaire);
    $req_prep->execute();
    $req_prep->setFetchMode(PDO::FETCH_CLASS, 'Model'.ucfirst(static::$table));
    if ($req_prep->rowCount()==0){
        return null;
        die();
    }else{
        $rslt = $req_prep->fetch();
        return $rslt;
    }
}
    public function connexion($lg,$pw) {
   ** $sql = "SELECT * from ".static::$table." WHERE ".static::$login."=:lg AND".static::$password."=:pw";**
    $req_prep = Model::$pdo->prepare($sql);
    $req_prep->bindParam(":lg", $lg);
    $req_prep->bindParam(":pw", $pw);
    $req_prep->execute();
    $req_prep->setFetchMode(PDO::FETCH_CLASS, 'Model'.ucfirst(static::$table));
    if ($req_prep->rowCount()==0){
        return null;
        die();
    }else{
        $rslt = $req_prep->fetch();
        return $rslt;
    }    
}

modelclient.php的一部分


 require_once ("Model.php"); 

class ModelClient extends Model{

 private $cin;
  private $clientname;
  private $clientemail;
   private $clientpw;
   private $tel;
    private $adress;

   protected static $table = 'client';
   protected static $primary = 'cin';
    protected static $login = 'clientemail';
   protected static $password = 'clientpw';

controllerclient的一部分


 case "connect":
    $pagetitle = "login ";
    $view = "login";
    require ("{$ROOT}{$DS}view{$DS}view.php");
    break;


    case"connected":
    if(isset($_REQUEST['lg']) && isset($_REQUEST['pw'])){
        $lg = $_REQUEST["lg"];
        $pw = md5($_REQUEST["pw"]);
    $cnx=ModelClient::connexion($lg,$pw);
    }
    if($cnx!=null){
    $pagetitle = "logged in  ";
    $view = "interface";
    require ("{$ROOT}{$DS}view{$DS}view.php");    
    }
    else
    $pagetitle = "login ";
    $view="login";
            require ("{$ROOT}{$DS}view{$DS}view.php");    
    break;

时间用完

0 个答案:

没有答案