Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Reset Password4:42 with Alena Holligan
Now that all our password checks pass, we can update the user with the new password.
If we pass all these checks.
We're ready to update the password.
Let's create a new function to do this.
The update password function will do a standard update query
where will pass the new hash password and the user ID.
Only the global $db and our try catch block.
We can return false if the password was not updated.
Password = password WHERE id = :userId.
Let's prepare a query and bind our variables.
And finally, execute.
If everything worked, we can return true.
Now let's use this function in our procedure.
Make sure we call the password hash function and our new password.
Finally, let's redirect the user with the success or error message.
Now we can add a link
in our navigation
if the user is
Let's test this out in the browser.
You need to sign up for Treehouse in order to download course files.Sign up