User Registration Using PHP MySQL

user registration using php mysql is an important concept for newbie programmer, user details like username, password, gender of the user and email address will be asked. After user provided their details, in this index.php itself database updation will be takes place and notification about registration will be shown alert box.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CREATE TABLE `freeze`.`tb` (
`id` INT( 3 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 20 ) NOT NULL ,
`password` VARCHAR( 20 ) NOT NULL ,
`gender` VARCHAR( 6 ) NOT NULL ,
`email` VARCHAR( 20 ) NOT NULL ,
PRIMARY KEY ( `id` )

) ENGINE = INNODB;

 

index.php

After submitting the values,  control  comes to this loop if(isset($_POST['submit'])) this loop will allow only when we click submit button and all values are stored in a variable. The stored variable values are added to the database.

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
$query=mysql_connect('localhost','root','');
mysql_select_db("freeze",$query);
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$gender=$_POST['gender'];
$email=$_POST['email'];
$query1=mysql_query("insert into tb values('','$username','$password','$gender','$email')");

if($query)
{
echo "user regsitration successful  ";
}
else
{
echo "There is a problem in user registration, Please try again ";
}
}
?>
<fieldset style="width:275px;">
<h1>User Registration / Signup</h1>
<form method="post" action="index.php">
Username: <input id="tb" type="text" name="username" /><br>
Password: <input id="tb" type="password" name="password" /><br>
Re-Password: <input id="tb" type="password" name="password1" /><br>
Gender
<input type="radio" name="gender" value="male" />Male
<input type="radio" name="gender" value="female" />Female<br>
Email: <input id="tb" type="text" name="email" /><br><br>
<input type="submit" name="submit">
</form>
</fieldset>

About prasad k

Prasad Kuppusamy has written 81 post in this blog.

i m php developer, web designer.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

coemption-lozenge