Difference between revisions of "PHP-and-MySQL/C4/User-Registration-Part-4/English"
From Script | Spoken-Tutorial
(Created page with '{| border=1 !Time !Narration |- |0:00 |Welcome to part 4 of "User Registration". We are going through these processes thoroughly. We are using security and checks for our "userna…') |
|||
(One intermediate revision by one other user not shown) | |||
Line 9: | Line 9: | ||
|If I am being confusing please let me know. Drop me an email or a comment through "youtube". | |If I am being confusing please let me know. Drop me an email or a comment through "youtube". | ||
|- | |- | ||
− | |0: | + | |0:20 |
− | |Getting | + | |Getting into "registering our user" process. |
|- | |- | ||
− | |0: | + | |0:23 |
− | |We need to connect to our database first. We are going to open | + | |We need to connect to our database first. We are going to open our table and input our values. |
|- | |- | ||
|0:29 | |0:29 | ||
Line 24: | Line 24: | ||
|Back to our page. I'll just go back into this and check all our checks that we had created first. | |Back to our page. I'll just go back into this and check all our checks that we had created first. | ||
|- | |- | ||
− | |0: | + | |0:48 |
− | |So I will click "Register" and it says "Please fill in all fields". | + | |So I will click "Register" and it says "Please fill in all the fields". |
|- | |- | ||
− | |0: | + | |0:55 |
− | |If I fill a variety of fields, then forget | + | |If I fill a variety of fields, then forget and click register its still saying a message. |
|- | |- | ||
− | |1: | + | |1:04 |
|So I am going to type "alex" and am going to choose my username. Then type my fullname and I am going to choose a password which is "abc". | |So I am going to type "alex" and am going to choose my username. Then type my fullname and I am going to choose a password which is "abc". | ||
|- | |- | ||
− | |1: | + | |1:16 |
− | |The next one I will just type a mix of characters. So, when I click register, it should say "Your passwords | + | |The next one I will just type a mix of characters. So, when I click register, it should say "Your passwords does not match". |
|- | |- | ||
− | |1: | + | |1:26 |
|So, go back to square one. We are going to type "Alex Garrett". We will choose a username. We are going to choose a password say "abc". | |So, go back to square one. We are going to type "Alex Garrett". We will choose a username. We are going to choose a password say "abc". | ||
|- | |- | ||
− | |1: | + | |1:40 |
|Since this is under 6 characters, when I click "Register" - "Passwords must be between 25 and 6 characters". So that check works. | |Since this is under 6 characters, when I click "Register" - "Passwords must be between 25 and 6 characters". So that check works. | ||
|- | |- | ||
− | |1: | + | |1:52 |
|Now what I will type is my fullname as "Alex Garrett" and my username as "alex". The password is going to be just a full length password. | |Now what I will type is my fullname as "Alex Garrett" and my username as "alex". 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!". | |More than 6 characters. I will click "Register". You can see that - "Length of the username or fullname is too long!". | ||
|- | |- | ||
− | |2: | + | |2:15 |
|So you can write these checks if you want. I'll leave it up to you. | |So you can write these checks if you want. I'll leave it up to you. | ||
|- | |- | ||
− | |2: | + | |2:20 |
|So, at the moment we have now got a successful form validation. | |So, at the moment we have now got a successful form validation. | ||
|- | |- | ||
− | |2: | + | |2:27 |
|Now what we will do is continue with registering our user. | |Now what we will do is continue with registering our user. | ||
|- | |- | ||
− | |2: | + | |2:32 |
|Now this form validation isn't good. Every time we get an error, these fields disappear; they are gone. | |Now this form validation isn't good. Every time we get an error, these fields disappear; they are gone. | ||
|- | |- | ||
− | |2: | + | |2:40 |
|And the user has to retype. | |And the user has to retype. | ||
|- | |- | ||
− | |2: | + | |2:43 |
|So what I am going to say is, we have got our fullname, username and password variables here. | |So what I am going to say is, we have got our fullname, username and password variables here. | ||
|- | |- | ||
− | |2: | + | |2:50 |
− | |Considering this | + | |Considering this php page itself, we can incorporate php into this html code over here. |
|- | |- | ||
− | |2: | + | |2:58 |
|Under your fullname I am going to say "value equal to" a value inside the box and open up a phptag. | |Under your fullname I am going to say "value equal to" a value inside the box and open up a phptag. | ||
|- | |- | ||
− | | | + | |3:07 |
|Close the php tag inside. Here I am going to echo username or rather fullname. | |Close the php tag inside. Here I am going to echo username or rather fullname. | ||
|- | |- | ||
− | |3: | + | |3:12 |
|I will do exactly the same with our username. So value equals, open php tags, close php tags and echo out username. | |I will do exactly the same with our username. So value equals, open php tags, close php tags and echo out username. | ||
|- | |- | ||
− | |3: | + | |3:23 |
|Make sure the line terminator is in there. | |Make sure the line terminator is in there. | ||
|- | |- | ||
− | |3: | + | |3:28 |
|Now what will happen is, let's say I choose this ridiculously long name here and choose a username say "alex". | |Now what will happen is, let's say I choose this ridiculously long name here and choose a username say "alex". | ||
|- | |- | ||
− | |3: | + | |3:37 |
− | |You don't want your passwords to be stored. So just leave that upto the user. | + | |If You don't want your passwords to be stored. So just leave that upto the user. |
|- | |- | ||
− | |3: | + | |3:43 |
|I've got a too long username and it should produce this error again. | |I've got a too long username and it should produce this error again. | ||
|- | |- | ||
− | |3 | + | |3:49 |
|When I click register, this time its kept our fullname and username. | |When I click register, this time its kept our fullname and username. | ||
|- | |- | ||
− | |3. | + | |3.55 |
|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.... | |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.... | ||
|- | |- | ||
− | |4: | + | |4:10 |
|It's annoying to type your name over and over again. | |It's annoying to type your name over and over again. | ||
|- | |- | ||
− | |4: | + | |4:14 |
|So using this, your php echo inside php tags, inside the values of your html input type and it so useful and much more convenient for the user and much more user friendly. | |So using this, your php echo inside php tags, inside the values of your html input type and it so useful and much more convenient for the user and much more user friendly. | ||
|- | |- | ||
− | |4. | + | |4.28 |
|Okay, otherwise echo "Success!!". I have not actually given a successful form yet. | |Okay, otherwise echo "Success!!". I have not actually given a successful form yet. | ||
|- | |- | ||
− | |4: | + | |4:35 |
|So I will type "Alex Garret" and my password is going to be over 6 characters and under 25 characters. | |So I will type "Alex Garret" and my password is going to be over 6 characters and under 25 characters. | ||
|- | |- | ||
− | |4: | + | |4:44 |
− | |Click "Register". Oh! an error | + | |Click "Register". Oh! an error message. Let's see. |
|- | |- | ||
− | |4: | + | |4:50 |
|We have picked up an error and.... - if string length of the password is greater than 25..... | |We have picked up an error and.... - if string length of the password is greater than 25..... | ||
|- | |- | ||
− | |4: | + | |4:56 |
− | |...or the string length of the password is lesser than 6.... echo password - should be enough.... but we have run into the same problem. | + | |...or the string length of the password is lesser than 6.... echo password - should be enough.... but we have to run into the same problem. |
|- | |- | ||
− | |5: | + | |5:05 |
− | |I have just | + | |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. |
|- | |- | ||
− | |5: | + | |5:19 |
− | |So again what I | + | |So again what I have to do is take this block of code, that has been encrypted our test. Cut out that and bring it down underneath "register the user". |
|- | |- | ||
− | |5: | + | |5:31 |
− | |So you can see from experience that | + | |So you can see from experience that ordering of things are very important. If you get errors like this go through your code.Look at them and realise what are you doing. |
|- | |- | ||
− | |5: | + | |5:43 |
− | | | + | |User echo things out in between your code, just as a sort of debug process. |
|- | |- | ||
− | |5: | + | |5:49 |
− | |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. |
|- | |- | ||
− | |5: | + | |5:56 |
|Click on "Register". We have got our "Success" message. | |Click on "Register". We have got our "Success" message. | ||
|- | |- | ||
− | | | + | |6:03 |
|So you see, going through your code helps to see if there are problems. | |So you see, going through your code helps to see if there are problems. | ||
|- | |- | ||
− | | | + | |6:07 |
|I am a bit quick at realising these. But sometimes I pause the video, have a look at the code and then resume the video. I don't like to keep the viewers on hold. | |I am a bit quick at realising these. But sometimes I pause the video, have a look at the code and then resume the video. I don't like to keep the viewers on hold. | ||
|- | |- | ||
− | |6: | + | |6:20 |
− | |You, too, will soon realise your mistakes. So we have got our "Success" and now we will say "open our database". | + | |So You, too, will soon realise your mistakes. So we have got our "Success" and now we will say "open our database". |
|- | |- | ||
− | |6: | + | |6:29 |
|To do this, we need our connect variable, no you don't... I am going to say my "sql connect". | |To do this, we need our connect variable, no you don't... I am going to say my "sql connect". | ||
|- | |- | ||
− | |6: | + | |6:37 |
|And am connecting to my local host server, which is my computer and root and my password is nothing. | |And am connecting to my local host server, which is my computer and root and my password is nothing. | ||
|- | |- | ||
− | |6: | + | |6:45 |
|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". | ||
|- | |- | ||
− | |6: | + | |6:55 |
|Even though this is obvious. This is php login and here I am going to say give a query. | |Even though this is obvious. This is php login and here I am going to say give a query. | ||
|- | |- | ||
− | | | + | |7:04 |
|So "query register". This is going to be equal to "mysqlL query". | |So "query register". This is going to be equal to "mysqlL query". | ||
|- | |- | ||
− | | | + | |7:11 |
|This is the important part of this tutorial where we actually input our values and we register our username. | |This is the important part of this tutorial where we actually input our values and we register our username. | ||
|- | |- | ||
− | |7: | + | |7:18 |
− | |Now let me scroll down so you can see. This is "INSERT INTO users". If we go back to here, this is it "php login" is our table that we have | + | |Now let me scroll down so you can see this . This is "INSERT INTO users". If we go back to here, this is it "php login" is our table that we have to select . So "mySQL select db php login". |
|- | |- | ||
− | |7: | + | |7:38 |
|And we are inserting into "users" which is our table into the database. | |And we are inserting into "users" which is our table into the database. | ||
|- | |- | ||
− | |7: | + | |7:44 |
− | |And we will say values brackets, each value of the table. So each field | + | |And we will say values brackets, each value of the table. So each field is present into the table. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|7:52 | |7:52 | ||
+ | |So if we go back till here and click on browse or structure - that one - we got id, name, username, password, date. So 1 2 3 4 5. | ||
+ | |- | ||
+ | |8:05 | ||
| 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. | ||
|- | |- | ||
− | |8: | + | |8:14 |
− | |So we | + | |So we need in here; the order is very important. |
|- | |- | ||
− | |8: | + | |8:18 |
− | |We have got our name, username, password, date. So this is just name, username. This is password, no need | + | |We have got our name, username, password, date. So this is just name, username. This is password, no need to repeat password, that is just for check and this is going to be the date. |
|- | |- | ||
− | |8: | + | |8:33 |
|So these variables here, if you are not too sure, are from up here, where we have our fullname, username, password and date. | |So these variables here, if you are not too sure, are from up here, where we have our fullname, username, password and date. | ||
|- | |- | ||
− | |8: | + | |8:44 |
− | |Lets 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 say "die". | + | |Lets 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". |
|- | |- | ||
− | |8: | + | |8:57 |
− | |"You have been registered | + | |"You have been registered return to login page". Put this as a link back to out index page in which the user could login. |
|- | |- | ||
− | |9: | + | |9:10 |
|You can see how it executes in a second and here is my previous page. | |You can see how it executes in a second and here is my previous page. | ||
|- | |- | ||
− | |9: | + | |9:16 |
|Lets say "Alex Garret". Choosing username as "alex" and this as your password. "You have been registered. Return to login page". | |Lets say "Alex Garret". Choosing username as "alex" and this as your password. "You have been registered. Return to login page". | ||
|- | |- | ||
− | |9: | + | |9:26 |
− | |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" | + | |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" |
|- | |- | ||
− | |9: | + | |9:37 |
|My password is my encrypted password and my date is date. | |My password is my encrypted password and my date is date. | ||
|- | |- | ||
− | |9: | + | |9:4 |
|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. | ||
|- | |- | ||
− | |9: | + | |9:50 |
− | |So I'll see you there. This is | + | |So I'll see you there. This is Siddharth dubbing for the Spoken Tutorial project. |
Latest revision as of 17:32, 18 April 2013
Time | Narration |
---|---|
0:00 | Welcome to part 4 of "User Registration". We are going through these processes thoroughly. We are using security and checks for our "username" and "password", which is really good. |
0:10 | If I am being confusing please let me know. Drop me an email or a comment through "youtube". |
0:20 | Getting into "registering our user" process. |
0:23 | We need to connect to our database first. We are going to open our table and input our values. |
0:29 | You might think this is very simple. |
0:33 | So, first of all, I am going to write a message saying "Success". |
0:39 | Back to our page. I'll just go back into this and check all our checks that we had created first. |
0:48 | So I will click "Register" and it says "Please fill in all the fields". |
0:55 | If I fill a variety of fields, then forget and click register its still saying a message. |
1:04 | So I am going to type "alex" and am going to choose my username. Then type my fullname and I am going to choose a password which is "abc". |
1:16 | The next one I will just type a mix of characters. So, when I click register, it should say "Your passwords does not match". |
1:26 | So, go back to square one. We are going to type "Alex Garrett". We will choose a username. We are going to choose a password say "abc". |
1:40 | Since this is under 6 characters, when I click "Register" - "Passwords must be between 25 and 6 characters". So that check works. |
1:52 | Now what I will type is my fullname as "Alex Garrett" and my username as "alex". 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!". |
2:15 | So you can write these checks if you want. I'll leave it up to you. |
2:20 | So, at the moment we have now got a successful form validation. |
2:27 | Now what we will do is continue with registering our user. |
2:32 | Now this form validation isn't good. Every time we get an error, these fields disappear; they are gone. |
2:40 | And the user has to retype. |
2:43 | So what I am going to say is, we have got our fullname, username and password variables here. |
2:50 | Considering this php page itself, we can incorporate php into this html code over here. |
2:58 | Under your fullname I am going to say "value equal to" a value inside the box and open up a phptag. |
3:07 | Close the php tag inside. Here I am going to echo username or rather fullname. |
3:12 | I will do exactly the same with our username. So value equals, open php tags, close php tags and echo out username. |
3:23 | Make sure the line terminator is in there. |
3:28 | Now what will happen is, let's say I choose this ridiculously long name here and choose a username say "alex". |
3:37 | If You don't want your passwords to be stored. So just leave that upto the user. |
3:43 | I've got a too long username and it should produce this error again. |
3:49 | When I click register, this time its kept our fullname and username. |
3.55 | 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.... |
4:10 | It's annoying to type your name over and over again. |
4:14 | So using this, your php echo inside php tags, inside the values of your html input type and it so useful and much more convenient for the user and much more user friendly. |
4.28 | Okay, otherwise echo "Success!!". I have not actually given a successful form yet. |
4:35 | So I will type "Alex Garret" and my password is going to be over 6 characters and under 25 characters. |
4:44 | Click "Register". Oh! an error message. Let's see. |
4:50 | We have picked up an error and.... - if string length of the password is greater than 25..... |
4:56 | ...or the string length of the password is lesser than 6.... echo password - should be enough.... but we have to run into the same problem. |
5:05 | 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. |
5:19 | So again what I have to do is take this block of code, that has been encrypted our test. Cut out that and bring it down underneath "register the user". |
5:31 | So you can see from experience that ordering of things are very important. If you get errors like this go through your code.Look at them and realise what are you doing. |
5:43 | User echo things out in between your code, just as a sort of debug process. |
5:49 | Now I will go back to my form and I'm going to retype my perfectly acceptable password in. |
5:56 | Click on "Register". We have got our "Success" message. |
6:03 | So you see, going through your code helps to see if there are problems. |
6:07 | I am a bit quick at realising these. But sometimes I pause the video, have a look at the code and then resume the video. I don't like to keep the viewers on hold. |
6:20 | So You, too, will soon realise your mistakes. So we have got our "Success" and now we will say "open our database". |
6:29 | To do this, we need our connect variable, no you don't... I am going to say my "sql connect". |
6:37 | And am connecting to my local host server, which is my computer and root and my password is nothing. |
6:45 | I am going to say "mySQL select db". This is going to select our database. So let's say "select data base". |
6:55 | Even though this is obvious. This is php login and here I am going to say give a query. |
7:04 | So "query register". This is going to be equal to "mysqlL query". |
7:11 | This is the important part of this tutorial where we actually input our values and we register our username. |
7:18 | Now let me scroll down so you can see this . This is "INSERT INTO users". If we go back to here, this is it "php login" is our table that we have to select . So "mySQL select db php login". |
7:38 | And we are inserting into "users" which is our table into the database. |
7:44 | And we will say values brackets, each value of the table. So each field is present into the table. |
7:52 | So if we go back till here and click on browse or structure - that one - we got id, name, username, password, date. So 1 2 3 4 5. |
8:05 | Here also we need 1 2 3 4 5. The id is auto increment, if you know from the last tutorial. |
8:14 | So we need in here; the order is very important. |
8:18 | We have got our name, username, password, date. So this is just name, username. This is password, no need to repeat password, that is just for check and this is going to be the date. |
8:33 | So these variables here, if you are not too sure, are from up here, where we have our fullname, username, password and date. |
8:44 | Lets 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". |
8:57 | "You have been registered return to login page". Put this as a link back to out index page in which the user could login. |
9:10 | You can see how it executes in a second and here is my previous page. |
9:16 | Lets say "Alex Garret". Choosing username as "alex" and this as your password. "You have been registered. Return to login page". |
9: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" |
9:37 | My password is my encrypted password and my date is date. |
9:4 | That's it. So in the next part I will show you how to tidy a few things out and test the login process. |
9:50 | So I'll see you there. This is Siddharth dubbing for the Spoken Tutorial project. |