thank you very much for your help, I incorporated your ereg into my code however im still getting a PHP error, grateful if you could take a look. The rest of the code has been tested and works fine.
Code:
<body>
<form name="search.php" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="id">ID Number</option>
<Option VALUE="surname">Surname</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
mysql_connect('localhost', 'un', 'pw') or die(mysql_error());
mysql_select_db("server") or die(mysql_error());
function checkfind($find) {
$find = strtoupper(str_replace(chr(32),'',$find));
if ereg ("^(ABCD[0-9]{2,3}|AB[0-9]{2,3})",$find);
return $find;
else
return FALSE;
}
$find = strip_tags($find);
$find = trim ($find);
$find = str_replace(' ','',$find);
$data = mysql_query("SELECT * FROM officers WHERE upper($field) LIKE'%$find%'");
while($result = mysql_fetch_array( $data ))
{
echo $result['id'];
echo " ";
echo $result['surname'];
echo "<br>";
echo $result['url'];
echo "<br>";
echo $result['expiry'];
echo " ";
echo "<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;
}
?>
</body>
Bookmarks