i've taken out some of the comments from the tutorial as they were in the way when i was reworking the script; the rest i left in.
<h2>Search</h2>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Search for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="fname">First Name</option>
<Option VALUE="lname">Last Name</option>
<Option VALUE="emali">Email Address</option>
<Option VALUE="gradyear">Graduation Year</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?php
if ($searching =="yes"
{
echo "<h2>Results</h2><p>";
if ($find == ""
{
echo "<p>You forgot to enter a search term";
exit;
}
mysql_connect("localhost", "root", "password"
or die(mysql_error());
mysql_select_db("contact"
or die('Could not connect' . mysql_error());
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"
;
//Formats the results
while($result = mysql_fetch_array( $data ))
{
echo $result['fname'];
echo " ";
echo $result['lname'];
echo " ";
echo $result['phone'];
echo " ";
echo $result['email'];
echo " ";
echo $result['gradyear'];
echo " ";
echo "<br /><br />";
}
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
echo "<b>Searched For:</b> " .$find;
}
?>
I'm pretty sure i copied everything right; i've been changing things around a bit to find a solution.