Difference between revisions of "PHP-and-MySQL/C4/User-Registration-Part-4/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
Sandhya.np14 (Talk | contribs) |
||
Line 201: | Line 201: | ||
|- | |- | ||
|05:30 | |05:30 | ||
− | |So you can see from experience that order of things | + | |So you can see from experience that order of things is very important. If you get errors like this go through your code. Look at them and realize what are you doing. |
|- | |- | ||
|05:42 | |05:42 | ||
− | |Use echo things out in between your code, just as | + | |Use '''echo''' things out in between your code, just as sort of debug process. |
|- | |- | ||
|05:48 | |05:48 | ||
− | |Now I will go back to my form and I'm going to retype my perfectly acceptable password in. | + | |Now I will go back to my '''form''' and I'm going to retype my perfectly acceptable password in. |
|- | |- | ||
Line 221: | Line 221: | ||
|- | |- | ||
|06:07 | |06:07 | ||
− | |I am a bit quick at realizing these. But sometimes I pause | + | |I am a bit quick at realizing these. But sometimes I pause video, I have a look at the code and then resume the video. I don't like to keep the viewers on hold. |
|- | |- | ||
|06:19 | |06:19 | ||
− | |So you | + | |So, you too will soon realize your mistakes. So we have got our "Success" and now we will say "open our database". |
|- | |- | ||
|06:28 | |06:28 | ||
− | |To do this, we need our connect variable, no you don't... I am saying my | + | |To do this, we need our connect variable, no you don't... I am saying my "sql connect()". |
|- | |- | ||
|06:36 | |06:36 | ||
− | |And I am connecting to my local host server | + | |And I am connecting to my "local host" server which is my computer and "root" and my password is nothing. |
|- | |- | ||
|06:44 | |06:44 | ||
− | |I am going to say "mySQL select db". This is going to select our database. So let's say "select data base" | + | |I am going to say "mySQL select db()". This is going to select our database. So let's say "select data base" |
|- | |- | ||
|06:55 | |06:55 | ||
− | | | + | |even though this is obvious. This is "php login" and here I am going to say give a query. |
|- | |- | ||
|07:03 | |07:03 | ||
− | |So "query register" is going to be equal to "mysql_query". | + | |So "query register" is going to be equal to "mysql_query()". |
|- | |- | ||
Line 260: | Line 260: | ||
|- | |- | ||
|07:38 | |07:38 | ||
− | |And we are inserting into "users" which is our table | + | |And we are inserting into "users" which is our '''table''' in the database. |
|- | |- | ||
|07:44 | |07:44 | ||
− | |And we will say | + | |And we will say "VALUES" brackets, each value of the table. So each field is present in the table. |
|- | |- | ||
|07:51 | |07:51 | ||
− | |So if we go back to here and click on | + | |So, if we go back to here and click on '''Browse''' or '''Structure''' - that one - we got '''id, name, username, password, date'''. So 1, 2, 3, 4, 5. |
|- | |- | ||
|08:04 | |08:04 | ||
− | | Here also we need 1 2 3 4 5. The id is auto increment, if you know from the last tutorial. | + | | Here also we need 1, 2, 3, 4, 5. The '''id''' is auto-increment, if you know from the last tutorial. |
|- | |- | ||
Line 280: | Line 280: | ||
|- | |- | ||
|08:18 | |08:18 | ||
− | |We have got our name, username, password, date. So this is just name, username. | + | |We have got our name, username, password, date. So this is just 'name', 'username'. |
|- | |- | ||
|08:24 | |08:24 | ||
− | |This is password, no need to repeat password, that was just for check and this is going to be the date. | + | |This is 'password', no need to repeat password, that was just for check and this is going to be the 'date'. |
|- | |- | ||
|08:33 | |08:33 | ||
− | |So these variables here, if you are not so sure, are up from here | + | |So these variables here, if you are not so sure, are up from here where we have our 'fullname', 'username', 'password' and 'date'. |
|- | |- | ||
|08:43 | |08:43 | ||
− | | | + | |Let's change this to 'fullname'. Okay, so this should work. After this is done I will say, "You have been registered". In fact, what I am going to do is I say '''die()'''. |
|- | |- | ||
Line 300: | Line 300: | ||
|- | |- | ||
|09:02 | |09:02 | ||
− | |Put this as a link back to out index page in which the user could login. | + | |Put this as a link back to out 'index page' in which the user could login. |
|- | |- | ||
Line 308: | Line 308: | ||
|- | |- | ||
|09:15 | |09:15 | ||
− | | | + | |Let's say "Alex Garret". Choosing username as "alex" and this as your password. "You have been registered!". Return to login page". |
|- | |- | ||
|09:26 | |09:26 | ||
− | |Now I will now check my database in | + | |Now, I will now check my database in '''Browse". You can see that I have got "Alex Garret". My "id" is 3, my "username" is "alex", |
|- | |- | ||
|09:36 | |09:36 | ||
− | | | + | |my password is my encrypted password and my "date" is this. |
|- | |- | ||
|09:41 | |09:41 | ||
− | |That's it. So in the next part I will show you how to tidy a few things out and test the login process. | + | |That's it. So, in the next part I will show you how to tidy a few things out and test the login process. |
|- | |- | ||
|09:49 | |09:49 | ||
− | |So I'll see you there. This is Sidharth dubbing for the Spoken Tutorial project. | + | |So I'll see you there. This is Sidharth, dubbing for the Spoken Tutorial project. |
Revision as of 16:29, 10 June 2015
Time | Narration |
---|---|
00:00 | Welcome to part 4 of User Registration. |
00:03 | We are going through these processes thoroughly. |
00:06 | We are using security and checks for our "username" and "password" which is really good. |
00:11 | If I am being confusing please let me know. Drop an email or a comment through "youtube". |
00:19 | Getting into "registering our user" process. |
00:22 | We need to connect to our database first. |
00:25 | We are going to open up our table and input our values. |
00:29 | You might think this is very simple. |
00:33 | So, first of all, I am going to write a message saying "Success". |
00:38 | Back to our page. I'll just go back into this and check all our checks that we had created first. |
00:47 | So, I will click "Register" and it says "Please fill in all the fields!". |
00:54 | If I fill a variety of fields then forget and click Register, it's still saying a message. |
01:03 | So, I am going to type "alex" and I am going to choose my username. |
01:09 | Then type my full name and I am going to choose a password which is "abc". |
01:15 | The next one, I will just type a mix of characters. |
01:19 | So, when I click Register, it should say "Your passwords do not match". |
01:25 | So, go back to square one. |
01:28 | We are going to type "Alex Garrett". |
01:32 | We will choose a username. We are going to choose a password say "abc". |
01:39 | Since this is under 6 characters, when I click "Register" - "Passwords must be between 25 and 6 characters". So that check works. |
01:52 | Now, what I will type is my fullname as "Alex Garrett" and my 'username' as "alex". |
02:00 | The password is going to be just a full length password. |
02:05 | More than 6 characters. I will click "Register". You can see that - "Length of the username or fullname is too long!". |
02:15 | So you can write these checks if you want. I'll leave it up to you. |
02:20 | So, at the moment we have now got a successful form validation. |
02:26 | Now, what we will do is continue with registering our user. |
02:31 | Now this form validation isn't good. Every time we get an error, these fields disappear; they are gone. |
02:40 | And the user has to retype. |
02:43 | So what I am going to say is, we have got our fullname, username and password variables here. |
02:50 | Considering this php page itself, we can incorporate php into this html code over here. |
02:57 | Under your fullname, I am going to say value equal to a value inside the box and open up a php tag. |
03:06 | Close the php tag inside. Here I am going to echo 'username' or rather '$fullname'. |
03:12 | I will do exactly the same with our 'username'. |
03:16 | So value equals open php tags, close php tags and echo out 'username'. |
03:23 | Make sure that line terminator is in there. |
03:27 | Now what will happen is, let's say I choose this ridiculously long name here and I choose a username say "alex". |
03:36 | If you don't want your passwords to be stored, so just leave that up to the user. |
03:43 | I've got a too long username and it should produce this error again. |
03:49 | When I click Register, this time it's kept our fullname and username. |
03.54 | So it's a rule. If you get an error and you have to retype your username, your fullname, your password or your firstname, middle name, your surname; I don't know how many fields are there in your user form. |
04:10 | It's annoying to type your name over and over again. |
04:13 | So using this, your php echo inside php tags, inside the values of your html input type and it is so useful and so much more convenient for the user and much more user friendly. |
04.28 | Okay, otherwise echo "Success!!". I have not actually given a successful form yet. |
04:34 | So, I will type "Alex Garret" and my password is going to be over 6 characters and under 25 characters. |
04:43 | Click "Register". Oh! an error message. Let's see. |
04:49 | We have picked up an error and.... - if the string length of the password is greater than 25 |
04:55 | ...or the string length of the password is lesser than 6.... echo password - should be enough.... but we have run into the same problem. |
05:04 | I have just realized that we have an encrypted value for our password and our md5 encrypted string is massive. It's much bigger than 25 characters. |
05:18 | So again what I have to do is, take this block of code that has been encrypting our page. Cut out that and bring it down underneath "register the user". |
05:30 | So you can see from experience that order of things is very important. If you get errors like this go through your code. Look at them and realize what are you doing. |
05:42 | Use echo things out in between your code, just as sort of debug process. |
05:48 | Now I will go back to my form and I'm going to retype my perfectly acceptable password in. |
05:55 | Click on "Register". We have got our "Success" message. |
06:02 | So you see, going through your code helps to see if there are problems. |
06:07 | I am a bit quick at realizing these. But sometimes I pause video, I have a look at the code and then resume the video. I don't like to keep the viewers on hold. |
06:19 | So, you too will soon realize your mistakes. So we have got our "Success" and now we will say "open our database". |
06:28 | To do this, we need our connect variable, no you don't... I am saying my "sql connect()". |
06:36 | And I am connecting to my "local host" server which is my computer and "root" and my password is nothing. |
06:44 | I am going to say "mySQL select db()". This is going to select our database. So let's say "select data base" |
06:55 | even though this is obvious. This is "php login" and here I am going to say give a query. |
07:03 | So "query register" is going to be equal to "mysql_query()". |
07:10 | This is the important part of the tutorial where we actually input our values and we register our username. |
07:18 | Now let me scroll down so you can see this is "INSERT INTO users". |
07:24 | If we go back to here, this is it "php login" is our table that we have selected. So "mySQL select db php login". |
07:38 | And we are inserting into "users" which is our table in the database. |
07:44 | And we will say "VALUES" brackets, each value of the table. So each field is present in the table. |
07:51 | So, if we go back to here and click on Browse or Structure - that one - we got id, name, username, password, date. So 1, 2, 3, 4, 5. |
08:04 | Here also we need 1, 2, 3, 4, 5. The id is auto-increment, if you know from the last tutorial. |
08:13 | So we just need in here; the order is very important. |
08:18 | We have got our name, username, password, date. So this is just 'name', 'username'. |
08:24 | This is 'password', no need to repeat password, that was just for check and this is going to be the 'date'. |
08:33 | So these variables here, if you are not so sure, are up from here where we have our 'fullname', 'username', 'password' and 'date'. |
08:43 | Let's change this to 'fullname'. Okay, so this should work. After this is done I will say, "You have been registered". In fact, what I am going to do is I say die(). |
08:56 | "You have been registered. Return to login page". |
09:02 | Put this as a link back to out 'index page' in which the user could login. |
09:08 | As you can see how it executes in a second and here is my previous page. |
09:15 | Let's say "Alex Garret". Choosing username as "alex" and this as your password. "You have been registered!". Return to login page". |
09:26 | Now, I will now check my database in Browse". You can see that I have got "Alex Garret". My "id" is 3, my "username" is "alex", |
09:36 | my password is my encrypted password and my "date" is this. |
09:41 | That's it. So, in the next part I will show you how to tidy a few things out and test the login process. |
09:49 | So I'll see you there. This is Sidharth, dubbing for the Spoken Tutorial project. |