php – How to update bcrypt password-ThrowExceptions

Exception or error:

I have a PHP exec script, which I want to update a user password using the exec command. The code is working except the password is not updating correctly.

$password = bcrypt('password12345);
$updateUserInfo = "mysql -u root  -D vanse -e \"UPDATE admins SET  first_name='$user->first_name', last_name='$user->last_name', email='$user->personal_email', password='$password' WHERE id='1'\" ";
return exec($updateUserInfo);

After the above code, my database will be updated and the password will now appear;

y0inY6NHi.Nq9a2QWvWcp7xeWMQDppVuRQHQFHnt9FPktEn0w.AWO6e

My question is how can I update bcrypt password in PHP exec() so that it will appear like this

$2y$10$inY6NHi.Nq9a2QWvWcp7xeWMQDppVuRQHQFHnt9FPktEn0w.AWO6e

in the database?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *