mysql – Password encrypted with BCRYPT in the database different from the password entered by the user when starting PHP session


I am trying to create a webpanel and a friend suggested that I encrypt the passwords of the users with BCRYPT for their security.

My problem when trying to login, the encrypted password that is saved in the database is different from the one that is sent in the SQL request.

For example, this is the main part of my code to validate the user's credentials:

File: passwordEncryptor.php

return password_hash ($ password, PASSWORD_BCRYPT, $ options);


File: login.php

In the event that the password stored in the database that was entered using the same function (passwordEncryptor) is "1234", that is "$ 2y $ 14 $ gyyo5OaMe4SeXIhRStbdjOnZZrb3IOdCoIOQlzPZj15MhGBHUjniq", because it is that at the time of authentication the query is:

SELECT * FROM pcd_users WHERE email = & # 39; & # 39; AND password = & # 39; $ 2and $ 14 $ O6iOBsAyv0JqwGudQhKPB.f68nLthfoMlJUU8n8zRuXxFJubhe7CO & # 39;