If you use files takes like this: (down you can see how to do it with mysql database...)
<?
$handle = @fopen("file.txt", "r");
if ($handle) {
while (!feof($handle))
{
$found=0;
$buffer = fgets($handle, 4096);
$str=explode(" ",$_POST["textfield"]);
foreach($str AS $s)
{
$buffer=str_replace($s,"<b>{$s}</b>",$buffer);
if( strstr(strtolower($buffer),strtolower($s)))
{
$found=1;
}
}
if($found==1)
{
$o++;
print "$o: $buffer<br>";
}
}
fclose($handle);
if($o==0)
print "No result";
}
?>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
With mysql:
<?
include("connec_to_Database.php");
if(isset($_POST["textfield"]))
{
$search=mysql_real_escape_string($_POST["textfield"]);
$sql="SELECT * FROM table WHERE tag_field LIKE '%$search%'";
$result=mysql_query($sql);
if(mysql_num_rows($result)>0)
{
$i=1;
while($rows=mysql_fetch_assoc($result))
{
extract($rows);
print "$i: Name: $name , Address: $address , Profession: $profession<br>";
$i++;
}
$i++;
}
else
print "No result";
}
?>
<form name="form1" method="post" action="?">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>