Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Giving the user a way they can update their password is important. In this video, we will create a User Profile page with a password reset form.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Now that we've set up the authentication
portion of the website,
0:04
we know that the users are allowed to be
here, but what are they allowed to do?
0:08
We want to make sure that
a user can vote on a book.
0:13
They can vote only once, but
they're allowed to change their vote.
0:17
They should not be able to
change anyone else's vote.
0:21
We also want to allow users to add
books and update their own books.
0:25
This is one area we may want to allow
0:30
certain users to have
access to all the books.
0:33
These will be our administrators.
0:36
Before we start handling our books,
there's another feature that should be
0:39
specific to a user,
the ability to change their password.
0:43
Let's add that functionality to our site
by providing a quick and easy way for
0:48
a user to change their own password, and
0:52
only their own password,
once they're logged in.
0:55
Let's start by adding a link in our
navigation if the user is logged in.
0:59
We'll add this with the logout,
so let's copy that item.
1:07
We'll then change it to My Account and
1:13
link to account.php.
1:19
Now we're ready to
create our account page.
1:22
We'll create a new file
called account.php.
1:25
Let's make sure it's not
in our template folder.
1:32
Great, now we're gonna copy
everything from register.php.
1:37
And we're ready to make some changes.
1:49
First, let's add the requireAuth function.
1:52
This means that a user is
required to be logged in.
2:00
This logged in user will be the one
whose password we'll be updating.
2:04
Next, we're going to change
the form action to changePassword.
2:08
Next, we'll change the heading,
We want this to read My Account.
2:18
Then we're going to add
a secondary header,
2:27
We'll add Change Password.
2:34
Next, we're going to change the first
field, Username, to CurrentPassword.
2:38
We've got the for, the id,
and the placeholder.
2:58
Our type will be password, And
3:04
our name will be current_password,
3:09
And our label will be Current Password.
3:17
Then for other password fields,
3:20
we're going to clearly state New Password.
3:24
Finally, we'll change the button
text to read Change Password.
3:35
Let's take a look at this in the browser.
3:46
When the use is logged in,
they see a link to my account.
3:50
And here we see a form
to update the password.
3:56
Now let's get that update working.
4:00
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up