Is it possible to change my search script to direct the client to a different page if there is an error?
Instead of having a text appear "No result have been found!", I would like them to be directed to search_error1.php.
Instead of having a text appear "You have not entered the search field", I would like them to be directed to search_error2.php.
<?php
$error = '';
if (isset($_POST['Submit'])) {
if (!empty($_POST['reg'])) {
$record = $_POST['reg'];
$query = mysql_query("SELECT * FROM reg_add WHERE reg='" . mysql_real_escape_string($record) . "'");
$result = mysql_num_rows($query);
if ($result != 0) {
$row = mysql_fetch_array($query);
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$reg = $row['reg'];
} else {$error = 'No result have been found!';}
} else {$error = 'You have not entered the search field, <a href="javascript:history.back(1)">Go back</a>.';}
}
if (!empty($error)) { echo $error; }
?>