你好每一個我試圖爲我的網站做一個登錄方法,我有一個小問題。我從PDO連接中獲取數據,但每次檢查密碼時都會返回false。我的變量是否錯誤? 這裏是我的sql查詢我如何使用PDO結果?
$this->result = $this->sql->prepare('SELECT username,password FROM User WHERE username=:username AND password=:password');
$this->result->bindParam(':username', $username, PDO::PARAM_STR);
$this->result->bindParam(':password', $password, PDO::PARAM_STR);
$this->result->execute();
,這裏是我的if語句:
$this->result=$this->result->fetch(PDO::FETCH_OBJ);
if (($password == $this->result->password) && ($username == $this->result->username)){
我沒有收到錯誤,它只是返回始終爲false。我沒有加密密碼,所以不是這個問題。我認爲$ this-> result-> password是個問題。任何人都可以糾正我嗎?
謝謝
好吧,我會嘗試它。非常感謝 –