I have this PHP code. The variable $password has the right password static assigned (no user input to validate).
$data['password'] returns the right hash too, when printing it out with echo.
But somehow the password_verify function doesnt work in this function. When I'm using it manually with the same inputs it workes fine.
Maybe there is something wrong with the PDO query, but I have no idea what.
$this->mysql->query("SELECT * FROM user WHERE username = :username LIMIT 1");
$this->mysql->bind(':username', $username);
$data = $this->mysql->single();
if($this->mysql->rowCount() == 1)
{
echo $data['password'];
if(password_verify($password, $data['password']))
{
echo "yees!";
}else{
$this->user_error = true;
}
}else{
$this->user_error = true;
}
So I figured it out.
There where some whitespaces in the array, but I haven't got any idea where they came from.
So I jused the trim()
function to remove these whitespaces and now everything works properly.
Thanks for quick help!