Hello every one i’m trying to do a login method for my website, and i’m having a small problem. I’m getting the data from PDO connection but every time im checking the password it returns false. is my variables wrong?
here is my sql query
$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();
and here is my if statement:
$this->result=$this->result->fetch(PDO::FETCH_OBJ);
if (($password == $this->result->password) && ($username == $this->result->username)){
i’m not getting error it just return always false. i’m not encrypting the password yet so is not this problem. i think $this->result->password is the problem. can anyone correct me please?
thank you
You can use this as well:
$this->result->execute();
And then use
fetchAlllike this: