skippt Posted August 22, 2013 Share Posted August 22, 2013 Hi, I'm currently using this tutorial to guide me and I'm trying out some of the examples but I don't really understand it. The version of PHP I'm using is 5.3.27 so I'm using this compatibility library. Okay, so my code for registering a user is below: $options = array('cost' => 11); $password = password_hash($password, PASSWORD_BCRYPT, $options); It takes the password inserted into a form, then I take the outputted $password and enter it into the database. For the password verify bit, I have: $hash = '$2y$11$6SXlwd2iKZcYuz9guncYXe39/x6lUR5u4EfJQr.qKhEPAuXFgLWeS'; if (password_verify($password, $hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } That works fine, except I need to grab the hash from the database. When I try to match that to the password entered into a form to the hash from the database, it comes up with invalid password. I think I'm doing this completely wrong. Can anyone help me out please? Quote Link to comment https://forums.phpfreaks.com/topic/281485-bcrypt-passwords-in-a-database/ Share on other sites More sharing options...
KevinM1 Posted August 22, 2013 Share Posted August 22, 2013 Are you hashing the entered password? Quote Link to comment https://forums.phpfreaks.com/topic/281485-bcrypt-passwords-in-a-database/#findComment-1446406 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.