Home » , » Registration Form PHP Script

Registration Form PHP Script

Written By 1 on Thursday, January 16, 2014 | 6:35 PM

This tutorial (Registration Form PHP Script) will let you know “How to create Registration Form Using PHP”. This is Step by step tutorial to create a registration form/Sign Up Form. I have created three major files named as:
  • registration_form.php
  • registration_script.php
  • success_register.php
But before, Sitting in a corner and start development, its important to idealize what you actually have to do. So i will recommend you to first idealize and then sketch that on paper and after the design is ready, start punching PHP. In this tutorial i have used the following design:
Firstly, Create a table into you database, table can keep the records specific fields easily. I have used the following Query to create a table and assign a primary key and make that Auto Increment so that it should keep on registering.
After the table is created, next task is to create a Registration Form in HTML. Your form should look like the following, You can add more fields in form, My form is short because i want to make you understand easily.


registration_form.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<html>
<head>
<title>Registration Form</title>
</head>

<body>
<table width="200" border="0" align="center">
<form id="form1" name="form1" method="post" action="registration_script.php">
<tr>
<td colspan="2"><h2 style="color:#FF000">Registration Form</h2></td>
</tr>
<tr>
<td>UserName:</td>
<td>
<input type="text" name="txtUser" id="txtUser" />

</td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="txtPassword" id="txtPassword" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="btnRegister" id="btnRegister" value="Register" />

</td>
</tr>
</form>
</table>
</body>
</html>
You have to take care of the name and id of the fields you are using, like i have done for my input fields.
Create another file and paste the following script into it.

registration_script.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    'vertrigo';
$database    =    'dbsneaker';

$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct');
mysql_select_db($database,$conn) or die('Database Information is not correct');

//===============End Server Configuration============

//=============Starting Registration Script==========

$userName    =    mysql_real_escape_string($_POST['txtUser']);

$password    =    mysql_real_escape_string($_POST['txtPassword']);
$password    =    md5($password);  //===Encrypt Password

if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register

{
$query    =    "insert into tbladmin(admin_usr_name,admin_pwd)values('$userName','$password')";
$res    =    mysql_query($query);
header('location:success_register.php');//Redirect To Success Page
}
I have used function md5(), it is used to encrypt the password. Like if i have inserted 12345 as my password then it will insert some encrypted data into the data base.
You are done! Just for your satisfaction, you can create another file to show a Success message. Here i have also show to insert a link with that to move to the Login Page. here i have tutorial tocreate a Login Page.

success_register.php

1
2
3
4
5
<body>

<h1> Congrats! you have Successfully Register</h1>
<a href="#"> Login</a>
</body>
If you still have any confusion then don’t forget to ask me. Comment here or mail me. I will respond to your emails frequently.

0 Comment:

Post a Comment