yanthan hadagaththa
test7.php
<?php
// Start the session
session_start();
?>
<form method="post" action="">
First Name:
<input type="text" value="<?php echo $_SESSION["first_name"]; ?>"><br>
Last Name:
<input type="text" value="<?php echo $_SESSION["last_name"]; ?>"><br>
Tel No:
<input type="text" value="<?php echo $_SESSION["tel"]; ?>"><br>
Marks:
<input type="text" value="<?php echo $_SESSION["marks"]; ?>"><br>
Grade :
<input type="text" value="<?php echo $_SESSION["grade"]; ?>"><br>
</form>
<?php
$db=new mysqli('localhost','root','','test2');
$nm = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$nm = htmlspecialchars(trim(stripslashes($_POST["first_name"])));
if($result=$db->query("SELECT * FROM people m INNER JOIN marks n
ON (m.first_name = n.first_name) WHERE m.first_name='$nm'"))
{
if($count=$result->num_rows)
{
//echo '<p>',$count, '</p>';
echo "Student Details",'<br>';
while($row = $result->fetch_object())
{
$_SESSION["first_name"] = $row->first_name;
//$lnm = $row->last_name;
$_SESSION["last_name"] = $row->last_name;
$_SESSION["tel"] = $row->tel;
$_SESSION["marks"] = $row->marks;
$_SESSION["grade"] = $row->grade;
}
}
}
include ("form3.php");
}
else
{
include ("form5.php");
echo "please Enter Your Name";
}
//$nm="roshan";
?>
form7.php
<?php
// Start the session
session_start();
?>
<form action="test7.php" method="POST">
Name: <input type="text" name="first_name"><br>
<input type="submit" value="Search">
</form>
<?php
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>