1 00:00:00 --> 00:00:03 Welcome to the 5th part of the User registration tutorial. 2 00:00:04 --> 00:00:10 We are going to tidy up a few bits and pieces together in our registration login process. 3 00:00:11 --> 00:00:13 Then we'll give a full test to see if it really works. 4 00:00:14 --> 00:00:18 In the last part, you saw that I registered myself in this database. 5 00:00:19 --> 00:00:23 Everything has worked out fine and I am at the login screen here. 6 00:00:24 --> 00:00:33 Lets see if I can login. Let's say username is "alex" and my password is the password that I used. 7 00:00:34 --> 00:00:39 I can see that when I click in login, again, "Incorrect password". 8 00:00:40 --> 00:00:43 This doesn't mean that my username hasn't been found. 9 00:00:44 --> 00:00:48 Let me type this in username and type in my password. 10 00:00:49 --> 00:00:51 It will tell me that user doesn't exit. 11 00:00:52 --> 00:00:57 But here, it is saying that my username does exist but my password is wrong. 12 00:00:58 --> 00:01:10 Now, the reason my password is wrong is that my plain text password here is being compared to my "md5-encrypted" password inside my data base. 13 00:01:11 --> 00:01:21 The way we do this is, we go back to our login page, which we covered in the previous tutorial - the userlogin tutorial. 14 00:01:22 --> 00:01:28 At the part where we compare our passwords to check if they match. 15 00:01:29 --> 00:01:34 That's checking our username there and this is checking our password. 16 00:01:35 --> 00:01:45 We need to check our password. At the moment, let's say I typed in my password as "slicer u k 1". 17 00:01:46 --> 00:01:52 So, this is the password I am typing in here. Its quite an odd one. 18 00:01:53 --> 00:02:01 "slicer u k 1". Okay and this is checking this and this password here is equal to slicer u k1. 19 00:02:02 --> 00:02:09 But this "password" is equal "dbpassword". So we are not getting the comparison. 20 00:02:10 --> 00:02:14 We get to choose this when we encrypt our password. 21 00:02:15 --> 00:02:25 So now this will actually be equal to this, so this is encrypted "slicer u k 1", which is equal to this "slicer u k 1". 22 00:02:26 --> 00:02:34 So we are comparing an md5 encrypted password to an md5 encrypted password in our database. 23 00:02:35 --> 00:02:38 Let me resubmit this form again Oh! error again! 24 00:02:39 --> 00:02:44 Let me try again. Click on login. No, its not working. 25 00:02:45 --> 00:02:55 Let's check this. "password" equals to "POST password" so md5 is the password. 26 00:02:56 --> 00:02:59 Let me go back and refresh this. 27 00:03:00 --> 00:03:05 I type my password. Al-right, I know what the problem is here. 28 00:03:06 --> 00:03:18 The problem here is that our md5 password is absolutely correct but it is being compared to a password which is cut short in our database. 29 00:03:19 --> 00:03:34 That's because if we go to our structure and go down to our password field here and edit this, we have currently got a length of 25 as its limit. 30 00:03:35 --> 00:03:39 So we are going increase the limit for this to, say, 100. 31 00:03:40 --> 00:03:49 I am not exactly sure how long an md5 string is, but I will say length value = 100. Save that. 32 00:03:50 --> 00:03:57 I am going to browse our table and delete this value. Then I am going to go back and re-register. 33 00:03:58 --> 00:04:01 So, register. Choose your username. 34 00:04:02 --> 00:04:13 Let's say "alex", like I said before. Choose a password, let's say "slicer u k 1". And I will click "Register". 35 00:04:14 --> 00:04:17 "You have been registered. Return to login page". 36 00:04:18 --> 00:04:20 Now, let's check our database again. 37 00:04:21 --> 00:04:26 This is looking longer already, it hasn't been cut short because I have changed the length of this. 38 00:04:27 --> 00:04:33 So now when I try to log back in and let me type this properly. 39 00:04:34 --> 00:04:40 We can login and we are in. Okay so check things like string length. 40 00:04:41 --> 00:04:42 Hopefully you have got this. 41 00:04:43 --> 00:04:47 If you want me to expand this tutorial please just let me know. 42 00:04:48 --> 00:04:49 And that is user registration. 43 00:04:50 --> 00:04:53 This is followed on from our user login tutorial. 44 00:04:54 --> 00:05:01 So by putting these together, we have got a fully functional user register and login process. 45 00:05:02 --> 00:05:06 I will be using this in a lot of my project work. Say for example. 46 00:05:07 --> 00:05:15 I might create a project on something that uses a user login and user registration. So I will be using this a lot. 47 00:05:16 --> 00:05:22 So check my projects on user login and registration for more information. 48 00:05:23 --> 00:05:29 If you have any questions or would like me to expand on anything, please just let me know. 49 00:05:30 --> 00:05:35 border=1