Difference between revisions of "PHP-and-MySQL/C4/User-Password-Change-Part-3/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
|-
 
|-
 
|00:03
 
|00:03
|This is the 3rd part of my “change password” tutorial. In this part, we’re going to change the password in the database.
+
|This is the 3rd part of my '''Change password''' tutorial. In this part, we’re going to change the password in the database.
 
|-
 
|-
 
|00:11
 
|00:11
Line 10: Line 10:
 
|-
 
|-
 
|00:14  
 
|00:14  
|We’re already connected here so there’s no need to reconnect, since that command has already been reissued.
+
|We’re already connected here, so there’s no need to reconnect since that '''command''' has already been reissued.
 
|-
 
|-
 
|00:23
 
|00:23
|I’ll create a new query called “query change” and that will be equal to “mysql query" function.
+
|I’ll create a new query called “$query change” and that will be equal to “mysql_ query()" function.
 
|-
 
|-
 
|00:30
 
|00:30
|Now, this is a new bit of code.  So I will scroll down so that you can see it easily.
+
|Now, this is a new bit of '''code'''.  So, I will scroll down so that you can see it easily.
 
|-
 
|-
 
|00:36
 
|00:36
|This is “UPDATE”.  So I’m going to say “UPDATE users” - which, you can see is our table - so to update our "users" table.
+
|This is “UPDATE”.  So I’m going to say '''UPDATE users''' - which, you can see is our table - so to update our "users" table.
 
|-
 
|-
 
|00:44
 
|00:44
|I will say “SET password equal to new password”
+
|I will say '''SET password''' equal to '$new password'
 
|-
 
|-
 
|00:51
 
|00:51
Line 28: Line 28:
 
|-
 
|-
 
|00:56
 
|00:56
|Then I’ll say WHERE username is equal to the "user" variable that I’ve got on my page currently.
+
|Then I’ll say '''WHERE username''' is equal to the '$user' variable that I’ve got on my page currently.
 
|-
 
|-
 
|01:03
 
|01:03
Line 37: Line 37:
 
|-
 
|-
 
|01:12
 
|01:12
|So since we’ve already processed our php session,  
+
|So, since we’ve already processed our php session,  
 
|-
 
|-
 
|01:18  
 
|01:18  
Line 43: Line 43:
 
|-
 
|-
 
|01:21
 
|01:21
|This piece of code is basically  saying  “update the table, change the password to the new password entered by the user. – this is the password they want.
+
|This piece of code is basically  saying  “update the table, change the password to the new password entered by the user. – This is the password they want
 
|-
 
|-
 
|01:32
 
|01:32
|and change this “where” to Alex,  
+
|and change this “WHERE” to Alex,  
 
|-
 
|-
 
|01:37
 
|01:37
Line 52: Line 52:
 
|-
 
|-
 
|01:40
 
|01:40
|So, this password will be changed because this username is equal to Alex.
+
|So, this password will be changed because this "username" is equal to "Alex".
 
|-
 
|-
 
|01:45
 
|01:45
|So this starts with 900 and as soon as we change it, we can refresh this and check that it actually has been changed.
+
|So, this starts with 900 and as soon as we change it, we can refresh this and check that it actually has been changed.
 
|-
 
|-
 
|01:56
 
|01:56
|So I’ll just add a few more things
+
|So I’ll just add a few more things.
 
|-
 
|-
 
|02:03
 
|02:03
|Let’s just put this back up here.
+
|Let’s just put this back, up here.
 
|-
 
|-
 
|02:06
 
|02:06
|And I’ll kill the page and say “die” and then say “Your password has been changed”.  
+
|And I’ll kill the page and say '''die()''' and then say “Your password has been changed”.  
 
|-
 
|-
 
|02:15
 
|02:15
|Then I’ll put a link in saying “return” and that’s going to return to the main page.
+
|Then I’ll put a link in saying “Return” and that’s going to return to the main page.
 
|-
 
|-
 
|02:23
 
|02:23
Line 76: Line 76:
 
|-
 
|-
 
|02:31
 
|02:31
|So “session destroy”.  
+
|So, “session_destroy()”.  
 
|-
 
|-
 
|02:33
 
|02:33
|The reason being, once the user has changed their password, this link will take them back to the main page, and this will destroy the session.  
+
|The reason being, once the users have changed their password, this link will take them back to the main page and this will destroy the '''session'''.  
 
|-
 
|-
 
|02:42
 
|02:42
|So they’ll need to login again using the new password.
+
|So, they’ll need to login again using the new password.
 
|-
 
|-
 
|02:59
 
|02:59
|So if we test this, remember in here, my current password is "abc" whose md5 hash starts with 900.
+
|So, if we test this, remember in here, my current password is "abc" whose 'md5 hash' starts with 900.
 
|-
 
|-
 
|03:00
 
|03:00
|And if I go back here, write my old password- "abc", my new password "123" and click “change password”. , we see that all the validation has been checked, our password has been changed,, and we get this message to return back to the main page.
+
|And if I go back here, write my old password- "abc", my new password "123" and click '''Change password''', we see that all the validation has been checked, our password has been changed and we get this message to return back to the main page.
 
|-
 
|-
 
|03:18
 
|03:18
|Now if I try to go back to the member page, you will see that you must be logged in. Our session has been destroyed, as we used our “session destroy” function here.  
+
|Now if I try to go back to the member page, you will see that you must be logged in. Our '''session''' has been destroyed as we used our “session destroy()” function here.  
 
|-
 
|-
 
|03:32
 
|03:32
Line 97: Line 97:
 
|-
 
|-
 
|03:43
 
|03:43
|If I try "123", you’re in, and evidence of this is shown in here.
+
|If I try "123", "you’re in!" and evidence of this is shown in here.
 
|-
 
|-
 
|03:50
 
|03:50
|Let’s just go back and click “browse”Lets scroll down and we can see that the password has been changed from 900 to 202.  
+
|Let’s just go back and click '''Browse'''Let's scroll down and we can see that the password has been changed from 900 to 202.  
 
|-
 
|-
 
|03:59
 
|03:59
Line 109: Line 109:
 
|-
 
|-
 
|04:11
 
|04:11
|All you need to do is learn your "sql" queries properly.  I have tutorials on that, too.
+
|All you need to do is learn your "sql" queries properly.  I have tutorials on that too.
 
|-
 
|-
 
|04:18
 
|04:18
|And you need to think logically about how to check your old password, and your two new passwords,
+
|And you need to think logically about how to check your old password, and your two new passwords.
 
|-
 
|-
 
|04:24
 
|04:24
|Obviously when we did our registration, we had a limit for how big the password should be.  
+
|Obviously, when we did our registration, we had a limit for how big the password should be.  
 
|-
 
|-
 
|04:31
 
|04:31
Line 121: Line 121:
 
|-
 
|-
 
|04:42
 
|04:42
|So really there are a lot of checks you can do, but this is the basic skeleton for changing the password in php using a mysql database.  
+
|So, really, there are a lot of checks you can do, but this is the basic skeleton for changing the password in php using a MySQL database.  
 
|-
 
|-
 
|04:53
 
|04:53
Line 127: Line 127:
 
|-
 
|-
 
|05:01
 
|05:01
|Thanks for watching! This is Harini dubbing for the Spoken Tutorial Project.
+
|Thanks for watching! This is Harini, dubbing for the Spoken Tutorial Project.
 
|-
 
|-

Latest revision as of 16:18, 8 June 2015

Time Narration
00:03 This is the 3rd part of my Change password tutorial. In this part, we’re going to change the password in the database.
00:11 We’ve already connected to our database up here.
00:14 We’re already connected here, so there’s no need to reconnect since that command has already been reissued.
00:23 I’ll create a new query called “$query change” and that will be equal to “mysql_ query()" function.
00:30 Now, this is a new bit of code. So, I will scroll down so that you can see it easily.
00:36 This is “UPDATE”. So I’m going to say UPDATE users - which, you can see is our table - so to update our "users" table.
00:44 I will say SET password equal to '$new password'
00:51 making sure I use inverted commas here.
00:56 Then I’ll say WHERE username is equal to the '$user' variable that I’ve got on my page currently.
01:03 Now this equates
01:07 to what we have in this column here.
01:12 So, since we’ve already processed our php session,
01:18 that is equal to "Alex".
01:21 This piece of code is basically saying “update the table, change the password to the new password entered by the user. – This is the password they want
01:32 and change this “WHERE” to Alex,
01:37 as this is equal to Alex.
01:40 So, this password will be changed because this "username" is equal to "Alex".
01:45 So, this starts with 900 and as soon as we change it, we can refresh this and check that it actually has been changed.
01:56 So I’ll just add a few more things.
02:03 Let’s just put this back, up here.
02:06 And I’ll kill the page and say die() and then say “Your password has been changed”.
02:15 Then I’ll put a link in saying “Return” and that’s going to return to the main page.
02:23 And that is “index.php”.
02:27 Before we kill the page, I’m going to destroy the session.
02:31 So, “session_destroy()”.
02:33 The reason being, once the users have changed their password, this link will take them back to the main page and this will destroy the session.
02:42 So, they’ll need to login again using the new password.
02:59 So, if we test this, remember in here, my current password is "abc" whose 'md5 hash' starts with 900.
03:00 And if I go back here, write my old password- "abc", my new password "123" and click Change password, we see that all the validation has been checked, our password has been changed and we get this message to return back to the main page.
03:18 Now if I try to go back to the member page, you will see that you must be logged in. Our session has been destroyed as we used our “session destroy()” function here.
03:32 And also, when I login again and type "abc" as my password which is my old password, we get an “Incorrect password” message.
03:43 If I try "123", "you’re in!" and evidence of this is shown in here.
03:50 Let’s just go back and click Browse. Let's scroll down and we can see that the password has been changed from 900 to 202.
03:59 Therefore this is a completely new hash and a completely new password.
04:06 So everything’s working fine. You can see that it is quite simple to do this.
04:11 All you need to do is learn your "sql" queries properly. I have tutorials on that too.
04:18 And you need to think logically about how to check your old password, and your two new passwords.
04:24 Obviously, when we did our registration, we had a limit for how big the password should be.
04:31 I’ll leave that to you to enter another check to see if the password should be bigger than 6 characters or no bigger than 25 characters.
04:42 So, really, there are a lot of checks you can do, but this is the basic skeleton for changing the password in php using a MySQL database.
04:53 Hope you enjoyed this. If you have any comments or questions please let me know. Also subscribe to video updates.
05:01 Thanks for watching! This is Harini, dubbing for the Spoken Tutorial Project.

Contributors and Content Editors

Gyan, Pratik kamble, Sandhya.np14