HTML File-
<html>
<head><title>Slip 5</title>
<script>
function search()
{
s=document.getElementById('txt1').value;
ob=new XMLHttpRequest();
ob.onreadystatechange=function()
{
if(ob.readyState==4 && ob.status==200)
{
document.getElementById('o').innerHTML=ob.responseText;
}
}
ob.open("GET","slip5.php?srch="+s);
ob.send();
}
</script>
</head>
<body>
<input type=text id=txt1 placeholder="Enter Employee name">
<input type=button value="Search" onclick="search()">
<h1 id="o">Output</h1>
</body>
</html>
PHP File-
<?php
$nm=$_GET['srch'];
$fp=fopen("employee.dat","r");
echo "<table border=1><tr><th>EmpId</th><th>Employee Name</th></tr>";
while($res=fscanf($fp,"%s %s"))
{
if($res[1]==$nm)
{
echo "<tr><td>".$res[0]."</td><td>".$res[1]."</td><tr>";
}
}
echo "</table>";
?>