PHP password_verify PDO returns false every time

Tewdyn

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;           
    }
Tewdyn

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!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive