Thursday, 16 November 2017

Show record through PHPMysql using web form

ShowForm.html
<!DOCTYPE html">
<html>
<head>
<title>Create Html Form</title>
</head>
<body bgcolor="pink">
<form action="ShowForm.php" method="post">
<table border="2" cellpadding="2" align="center">
    <tr align="center"><td colspan="3"><u><i><b>Registration Page</b></i></u></td></tr>
<tr><td><b>User ID:</b></td><td> <input type="text" name="userid" placeholder="Enter UserID" value=""/><input type="submit" name="submit" value="UserId"/></td></tr><br/>
<tr><td><b>User Name:</b></td><td> <input type="text" name="username" placeholder="Enter User Name" value=""/></td></tr><br/>
<tr><td><b>State:</b></td><td> <input type="text" name="state" placeholder="Enter State" value=""/></td></tr><br/>
<tr><td><b>City:</b></td><td> <input type="text" name="city" placeholder="Enter City" value=""/></td></tr><br/>
<tr><td><b>Phone no:</b></td><td><input type="text" name="phoneno" placeholder="Enter Phone No" value=""/></td></tr><br/>
<tr><td><b>Pin:</b></td><td><input type="text" name="pin" placeholder="Enter Pin No" value=""/></td></tr></br>
<tr><td><b>Gender</b></td></tr><br/>
<tr><td><b>Male:</b></td><td><input type="radio" name="gender" value="Male" checked/></td></tr><br/>
<tr><td><b>Female:</b></td><td><input type="radio" name="gender" value="Female" /></td></tr><br/>
<tr align="center"><td colspan="2"><b><input type="submit" name="submit" value="Insert"/><input type="submit" name="submit" value="Update"/><input type="submit" name="submit" value="Delete"/><a href="ShowForm.php" >ShowData</a><input type="button" onClick="location.href='ShowForm.php';" value="ShowData"/></b></td></tr><br/>
</table>
</form>
</body>
</html>

ShowForm.php
<!DOCTYPE html">
<html>
<head>
<title>Create Html Form</title>
</head>
<body bgcolor="pink">
<?php
$con=mysqli_connect("localhost", "root", "", "mydatabase");
$sql = "SELECT * from registration";
$result = mysqli_query($con, $sql);
echo "<table border='2'>";
echo "<tr><th>UderId</th><th>Name</th><th>State</th><th>City</th><th>Phone No</th><th>Pin</th><th>Gender</th></tr>";
while($contact = mysqli_fetch_array($result)) 

echo "<tr><td>";
echo $contact['UserId'];
echo "</td><td>";
echo $contact['UserName'];
echo "</td><td>";
echo $contact['State'];
echo "</td><td>";
echo $contact['City'];
echo "</td><td>";
echo $contact['PhoneNo'];
echo "</td><td>";
echo $contact['Pin'];
echo "</td><td>";
echo $contact['Gender'];
echo "</td></tr>";

echo "</table>";
?>
</body>
</html>

1 comments: