Look at the examples for password_hash()
and password_verify()
together.
The hash-string that's produced by password_hash
is self-describing: it incorporates an indication of both the algorithm and the random-salt that was used. password_verify
knows about all this. It knows how to "do the right thing" for passwords both recent and vintage.
Therefore, simply query the database to get the (hashed ...) password for this user. Then, use password_verify()
to see if this hash-value matches this password-value.
You can't query for the user-name AND password
at the same time. Query only for the user-name, get the hashed value, and use password_verify()
to check it.