Registration form
- Database: `db1`
Table structure for table `reg`
CREATE TABLE IF NOT EXISTS `reg` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(20) NOT NULL,
`Photo` varchar(50) NOT NULL,
`Userid` varchar(30) NOT NULL,
`Password` varchar(30) NOT NULL,
`Email` varchar(50) NOT NULL,
`DateOfBirth` date NOT NULL,
`City` varchar(20) NOT NULL,
`Gender` varchar(20) NOT NULL,
`Address` varchar(200) NOT NULL,
`Mobile` double NOT NULL,
`Pin` int(11) NOT NULL,
`Hobby` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ;
2. index.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RegistrationApplication</title>
<script language="javascript" type="text/javascript">
function validate()
{
var x=document.getElementById("txtName");
if(x.value.length==0)
{
alert("plese enter your name");
x.focus();
return false;
}
var x1=document.getElementById("txtUser");
if(x1.value.length==0)
{
alert("plese enter userid");
x.focus();
return false;
}
var y=document.getElementById("txtPass");
if(y.value.length==0)
{
alert("Password must Be Compulsary");
y.focus();
return false;
}
var z=document.getElementById("txtCnfPass");
if(y.value != z.value)
{
alert("Password And Conform password Must be Same");
x.focus();
return false;
}
var email=document.getElementById("txtEmail");
if(email.value.length==0)
{
alert("Enter Email id")
email.focus();
return false;
}
var address=document.getElementById("txtareaAddress");
if(address.value.length==0)
{
alert("Enter address")
address.focus();
return false;
}
var Phone=document.getElementById("txtPhone");
if(Phone.value.length==0)
{
alert("Enter Phone No")
Phone.focus();
return false;
}
var pin=document.getElementById("txtPin");
if(pin.value.length==0)
{
alert("Enter Pincode")
pin.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form action="Reg.php" method="post" name="form1" enctype="multipart/form-data">
<div align="center">
<table width="400" border="1">
<tr>
<td bgcolor="#CC66FF" align="center" colspan="2"><h3>ApplicationForm</h3></td>
</tr>
<tr>
<td>Name:-</td>
<td><input name="txtName" id="txtName" type="text" /></td>
</tr>
<tr>
<td>Photo:-</td>
<td><input name="file1" id="file1" type="file" /></td>
</tr>
<tr>
<td>UserId:-</td>
<td><input name="txtUser" id="txtUser" type="text" /></td>
</tr>
<tr>
<td>Password:-</td>
<td><input name="txtPass" id="txtPass" type="password" /></td>
</tr>
<tr>
<td>CnfPass:-</td>
<td><input name="txtCnfPass" id="txtCnfPass" type="password" /></td>
</tr>
<tr>
<td>Email:-</td>
<td><input name="txtEmail" id="txtEmail" type="text" /></td>
</tr>
<tr>
<td>DateOfBirth:-</td>
<td><input name="txtDateOfBirth" id="txtDateOfBirth" type="text" /></td>
</tr>
<tr>
<td>City:-</td>
<td><select name="ComboState">
<option selected="selected" value="select">---Select---</option>
<option>Sachin</option>
<option>Surat</option>
<option>Baroda</option>
<option>Valsad</option>
<option>Vapi</option>
</select></td>
</tr>
<tr>
<td>Gender:-</td>
<td>
<label>
<input type="radio" checked="checked" name="RadioGroup1" value="Male" id="RadioGroup1_0" />
Male</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Female" id="RadioGroup1_1" />
Female</label>
<br />
</td>
</tr>
<tr>
<td>Address:-</td>
<td><textarea name="txtareaAddress" id="txtareaAddress" cols="15" rows="2"></textarea></td>
</tr>
<tr>
<td>PhoneNo:-:-</td>
<td><input name="txtPhone" type="text" id="txtPhone" /></td>
</tr>
<tr>
<td>Pincode:-</td>
<td><input name="txtPin" type="text" id="txtPin" /></td>
</tr>
<tr>
<td>Hobby:-</td>
<td><p>
<label>
<input type="checkbox" name="hobbies[]" value="Tennis" />
Tennis</label>
<br />
<label>
<input type="checkbox" name="hobbies[]" value="Cricket" />
Cricket</label>
<br />
<label>
<input type="checkbox" name="hobbies[]" value="FootBall" />
FootBall</label>
<br />
<label>
<input type="checkbox" name="hobbies[]" value="Badminten" />
Badminten</label>
</p></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="Submit" type="submit" value="SignUp"
onclick="return validate()"/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
3.config.php
<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('db1')or die(mysql_error());
?>
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('db1')or die(mysql_error());
?>
4. Reg.php
<?php
include_once("config.php");
if(isset($_POST['Submit']))
{
$name=$_POST['txtName'];
$photo=$_FILES['file1']['name'];
move_uploaded_file($_FILES['file1']['tmp_name'],"images/$photo");
$Userid= $_POST['txtUser'];
$pass=$_POST['txtPass'];
$cnfpass=$_POST['txtCnfPass'];
$email=$_POST['txtEmail'];
$dateofbirth=$_POST['txtDateOfBirth'];
$city=$_POST['ComboState'];
$gender=$_POST['RadioGroup1'];
$Address=$_POST['txtareaAddress'];
$phone=$_POST['txtPhone'];
$pin=$_POST['txtPin'];
$hobby= $_POST['hobbies'];
for($i=0; $i<count($hobby); $i++)
{
$x.=$hobby[$i]."|";
}
if(strcmp('$pass','$cnfpass'))
{
$reg=mysql_query("insert into reg(Name,Photo,Userid,Password,Email,DateOfBirth,City,Gender,Address,
Mobile,Pin) Values('$name','$photo','$Userid','$pass','$email','$dateofbirth','$city','$gender',
'$Address','$phone','$pin')")or die(mysql_error());
echo "Data Insert Succsessfully....";
}
else
{
echo "Password Does not Match..";
}
}
?>
include_once("config.php");
if(isset($_POST['Submit']))
{
$name=$_POST['txtName'];
$photo=$_FILES['file1']['name'];
move_uploaded_file($_FILES['file1']['tmp_name'],"images/$photo");
$Userid= $_POST['txtUser'];
$pass=$_POST['txtPass'];
$cnfpass=$_POST['txtCnfPass'];
$email=$_POST['txtEmail'];
$dateofbirth=$_POST['txtDateOfBirth'];
$city=$_POST['ComboState'];
$gender=$_POST['RadioGroup1'];
$Address=$_POST['txtareaAddress'];
$phone=$_POST['txtPhone'];
$pin=$_POST['txtPin'];
$hobby= $_POST['hobbies'];
for($i=0; $i<count($hobby); $i++)
{
$x.=$hobby[$i]."|";
}
if(strcmp('$pass','$cnfpass'))
{
$reg=mysql_query("insert into reg(Name,Photo,Userid,Password,Email,DateOfBirth,City,Gender,Address,
Mobile,Pin) Values('$name','$photo','$Userid','$pass','$email','$dateofbirth','$city','$gender',
'$Address','$phone','$pin')")or die(mysql_error());
echo "Data Insert Succsessfully....";
}
else
{
echo "Password Does not Match..";
}
}
?>