1 00:00:00 --> 00:00:08 Welcome to the Spoken Tutorial on how to create a user registration form and how to register a user into mysql database. 2 00:00:09 --> 00:00:18 One suggestion before starting this tutorial is that you watch my "User login" tutorials first. I've posted a link to it. 3 00:00:19 --> 00:00:33 I would suggest that you do so before going through these tutorials. The reason I have created "User login" before "User registration" is because I find it a lot easier to do the "User login" process before doing the "Registration" process. 4 00:00:34 --> 00:00:42 Once you've got the "login" process right and you've got the fields in the database you can start our registration process. 5 00:00:43 --> 00:00:48 I just find it a lot more easier to this way, as you know what you're registering in to your data base. 6 00:00:49 --> 00:00:55 To start with, in the first part we will create our form and check for the existence of my login information. 7 00:00:56 --> 00:01:02 From my existing tutorials, I am using my "login session" folder. 8 00:01:03 --> 00:01:11 This here is my login session and all my fields but here I will create a new file. 9 00:01:12 --> 00:01:14 Just add some tags first. 10 00:01:15 --> 00:01:21 I will create this inside my login session folder with the "index dot php" which is the main page you saw. 11 00:01:22 --> 00:01:31 Log in, log out and the member page if users are logged in and I will save this as "register dot php". 12 00:01:32 --> 00:01:39 I am creating a user registration form so that the user can register before they decide to login. 13 00:01:40 --> 00:01:47 I have created my "register dot php" and I am also going to open my index file. I will create a link underneath the form. 14 00:01:48 --> 00:02:01 And this is going to be just a link to that register page and I will type "Register" here. 15 00:02:02 --> 00:02:08 So what we get here is a link called "Register" which goes to our page where we have nothing at the moment. 16 00:02:09 --> 00:02:19 Following from the last tutorial where we could login, I will just put a link to a page that you can register before you do this. 17 00:02:20 --> 00:02:28 Before we were just typing data into our database. If I open up a new window, I will go across to "php my admin". 18 00:02:29 --> 00:02:37 And this is the database that will be used called "php login" and this is my "users" table. 19 00:02:38 --> 00:02:46 You can see I have added an extra field called "name" and I will add another field called "date". 20 00:02:47 --> 00:03:03 At the end of the table that's going to be called "date" and it will be in date format. So where is it? Um.... Here it is. 21 00:03:04 --> 00:03:14 Before you get confused about what the date will be, it will be the current date when the users registered and we go there and save that. 22 00:03:15 --> 00:03:28 So from the last tutorial on the "User login" we just have id, username and password. Now I have added a name so its going to be the user name and we've added date, the date when he registered. 23 00:03:29 --> 00:03:34 Just browse in here. We have got a couple of values here already. 24 00:03:35 --> 00:03:39 I will delete these because I am registering my users. So I can start from a clean database. 25 00:03:40 --> 00:03:48 Assuming I have got no users at all and I have got my link here to the register page, here is my register page. 26 00:03:49 --> 00:03:58 Now I'll briefly explain this html code which tells you how to create this page and we will have a form first of all. 27 00:03:59 --> 00:04:06 This is going to be a self submitting form. It's going to submit back to "register dot php". 28 00:04:07 --> 00:04:12 And we are going to create a table and inside this we will have a row here. 29 00:04:13 --> 00:04:20 Then we have two columns, so two td blocks here and the 1st one will have, say your fullname 30 00:04:21 --> 00:04:28 I leave it up to you. Just to speed up I will do it this way. 31 00:04:29 --> 00:04:37 In our second column here, I will put my input type as "text" and my name equals "fullname". 32 00:04:38 --> 00:04:46 So you can see at the moment, let me go back to my original page, click on register. 33 00:04:47 --> 00:04:55 You can see, this is one column here, split down here. This is another column with the input box in. 34 00:04:56 --> 00:05:06 And I will also go up here and inside the php code, I will echo out a header. I will explain a bit later why I have done this. 35 00:05:07 --> 00:05:14 So we got that. At the moment we have this. To speed up, I will just copy and paste this down. 36 00:05:15 --> 00:05:21 So make sure you choose from "t r" till "end t r". 37 00:05:22 --> 00:05:31 I will paste it down and then I will say "Choose a username" and obviously I will change this to "username". 38 00:05:32 --> 00:05:46 I will paste that again and say "Choose a password". This text is just to secure in case any one's looking over our users' shoulder or any screen capture software being used to infiltrate this computer. 39 00:05:47 --> 00:05:57 And the next one down here I will just copy and paste this here to say "Repeat your password". 40 00:05:58 --> 00:06:06 Again "password" here. 41 00:06:07 --> 00:06:09 We can't say "password" again so I will call this "repeat password". 42 00:06:10 --> 00:06:19 We will use this to compare the passwords once they have been submitted as a safety measure in case the user made any mistakes. 43 00:06:20 --> 00:06:23 And we don't need any other field. That is the last one. 44 00:06:24 --> 00:06:30 What we do need is the "date". But I will do that when I submit the form. 45 00:06:31 --> 00:06:36 Okay so this is our form created. Lets go back and refresh. 46 00:06:37 --> 00:06:41 You can see how this is evenly arranged, that's why we have used a table. 47 00:06:42 --> 00:06:44 We need a submit button also. 48 00:06:45 --> 00:06:47 Underneath our table, I will create a paragraph break. 49 00:06:48 --> 00:06:53 And my input type here is going to be "submit"; my name is going to be "submit". 50 00:06:54 --> 00:06:56 And we have to check the existence and the value will just be "register". 51 00:06:57 --> 00:07:04 Lets refresh. There we are, you can see that the password fields have been blanked out. 52 00:07:05 --> 00:07:11 Also we have a fullname and username there for the users to type their values. 53 00:07:12 --> 00:07:15 Okay that's about it. I will stop the tutorial here. 54 00:07:16 --> 00:07:24 If you are following this step by step, make sure you have got your form written out and try out another design if you wish. 55 00:07:25 --> 00:07:29 I wish I had more time to do it. So go ahead and create your form as you want. 56 00:07:30 --> 00:07:32 Do anything you want to it. Change these labels. 57 00:07:33 --> 00:07:34 Just make sure you got your boxes and your register. 58 00:07:35 --> 00:07:43 In the next part we will talk about checking that the user has typed each one of these fields in. 59 00:07:44 --> 00:07:58 We will compare the passwords to see if they match. I mean if I say there are two passwords and these don't match as they differ in character length, then the user can't register as they might have made a mistake. 60 00:07:59 --> 00:08:06 I am sure most of you watching must have registered at some point and would have typed in your password again. 61 00:08:07 --> 00:08:16 We will also encrypt our passwords and remove any dangerous or any pretentiously dangerous html tags from these forms. So we'll have some bit of security to our registration form. 62 00:08:17 --> 00:08:22 So I see in the next part. Thanks for watching. This is Sidhartha dubbing for the Spoken Tutorial project.