Leave a comment

User Registration form in PHP and MySQL

This is SIMPLE registration Code…Feel Free To Edit.. ..

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
<html>
<head>
<title>New user registration</title>
</head>
<body>
<?php
include('db.php');
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$err='';
if($_POST['username']=="")
{
$err.="Please type username";
}
if($_POST['password']=="")
{
$err.="Please type password";
}
if($_POST['password']!=$_POST['password1'])
{
$err.="Password mismatch";
}
if($err=="")
{
$query=mysql_query("insert into tab (id,username, password) values('','$username','$password')");
if($query)
{
echo "<script type='text/javascript'>alert('User registered successfully')</script>";
}
else
{
echo "<script type='text/javascript'>alert('there is a problem in user registration ')</script>";
}
}
else
{
echo $err;
}
}
else
{
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<h1>New user registration</h1><br><br>
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
Re-enter Password: <input type="password" name="password1"><br><br>
<input type="submit" name="submit">
</form>
<?php
}
?>
</body>
</html>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: