Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Now that all our password checks pass, we can update the user with the new password.
-
0:00
If we pass all these checks.
-
0:02
We're ready to update the password.
-
0:04
Let's create a new function to do this.
-
0:17
The update password function will do a standard update query
-
0:21
where will pass the new hash password and the user ID.
-
0:31
Only the global $db and our try catch block.
-
0:51
We can return false if the password was not updated.
-
0:58
Update users.
-
1:02
Send.
-
1:07
Password = password WHERE id = :userId.
-
1:22
Let's prepare a query and bind our variables.
-
1:54
And finally, execute.
-
2:02
If everything worked, we can return true.
-
2:06
Now let's use this function in our procedure.
-
2:19
Make sure we call the password hash function and our new password.
-
2:40
Finally, let's redirect the user with the success or error message.
-
3:29
Now we can add a link
-
3:36
in our navigation
-
3:43
if the user is
-
3:47
logged in.
-
4:08
Let's test this out in the browser.
You need to sign up for Treehouse in order to download course files.
Sign up