I have created register form using php. I have index.php,submit.php,functions.php and script.
Now it works fine, and i need to retrieve the data from database and display in front end.
I am new to php, and i am learning. please help me to do this.
This is my data.php:
<?php
include ('condb.php');
$query = mysql_query("select * from test where id='".$_GET['id']."'");
$row = mysql_fetch_array($query);
?>
<body>
<h3>Employee Detail</h3>
<p>Emp Name:</p> <?php echo $row['fname'];?>
<p>LastName:</p> <?php echo $row['lname'];?>
</body>
<?php ?>
and this is action.php:
<?php
include('condb.php');
extract($_POST);
$que=mysql_query("INSERT INTO test (id, fname, lname) VALUES ('$id', '$fname', '$lname')") or die("Error Msg!");
if($que)
{
header('Location: data.php?id='.$id.'');
}
?>
index.html:
<body bgcolor="#2E2E2E">
<table align="center" cellpadding="5" style="background:#A4A4A4; border-radius:4px; margin-top:40px; padding:15px;">
<h1 style="text-align:center; color:white; margin-top:50px">Employee Registration Form</h1>
<form method="post" action="action.php">
<tr><td>First Name:</td><td> <input type="text" id="fname" name="fname" required /></td></tr>
<tr><td>Last Name:</td><td> <input type="text" id="lname" name="lname"/></td></tr>
<tr><td></td><td><input type="submit" value="Register Me!"/></td></tr>
</form>
</table>
</body>
and condb.php:
<?php
$con=mysql_connect("localhost","root","")or die("Error!");
mysql_select_db("test") or die(mysql_error());
?>