user.html
<html>
<head>
<title> user registration information</title>
</head>
<body>
<h3 align="center">user registration information</h3>
<form name="registration" method="post" action="storeuser.php">
<table align="center" height="450">
<tr>
<td>Name:</td>
<td><input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td>Address:</td>
<td><textarea rows="4" cols="30" name="address" id="address"></textarea> </td>
</tr>
<tr>
<td>Date of Birth:</td><td><input type="date" name="dob" id="dob"/></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="number" name="age" id="age" /></td>
</tr>
<tr>
<td>Aadhar Number:</td>
<td><input type="text" name="aadhar" id="aadhar" /></td>
</tr>
<tr>
<td>Gender:</td>
<td><input type="radio" name="gender" value="male" /> Male
<input type="radio" name="gender" value="female" /> Female</td>
</tr>
<tr>
<td colspan="2" align="center">
<input value="Submit" type="submit"/>
<input value="reset" type="reset" />
</td>
</tr>
</table>
</body>
</html>
storeuser.php
<?php
$link = mysqli_connect("localhost", "root", "", "wit");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$user = mysqli_real_escape_string($link, $_POST['name']);
$address = mysqli_real_escape_string($link, $_POST['address']);
$dob = mysqli_real_escape_string($link, $_POST['dob']);
$age = mysqli_real_escape_string($link, $_POST['age']);
$aadhar = mysqli_real_escape_string($link, $_POST['aadhar']);
$gender = mysqli_real_escape_string($link, $_POST['gender']);
// attempt insert query execution
$sql = "INSERT INTO storeuser (name, address,dob,age,aadhar,gender) VALUES ('$user', '$address',
'$dob','$age','$aadhar','$gender')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
$link_address="store.html";
echo "<a href='".$link_address."'>Go to Register Page</a>";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
<a href="display.php">|Display|</a>
display.php
<html>
<body>
<?php
mysql_connect("localhost","root","");
mysql_select_db("wit");
$r=mysql_query("select * from storeuser");
echo"<table border=1>";
echo"<tr><th>User Name</th><th>Address</th><th>Date of Birth</th><th>Age</th><th>Aadhar Number</th><th>Gender</th></tr>";
while ($row=mysql_fetch_array($r))
{ echo"<tr>";
echo "<td>".$row['0']."</td>"."<td>".$row['1']."</td>"."<td>".$row['2']."</td>"."<td>".$row['3']."</td>"."<td>".$row['4']."</td>"."<td>".$row['5']."</td>";
echo "</tr>";
}
echo"</table>";
?>
<a href="store.html">|Home|</a>
</body>
</html>