如果出现错误,是否可以更改我的搜索脚本以将客户端引导到不同的页面?
我希望将它们定向到 search_error1.php,而不是出现文本“未找到结果!”。
我希望将它们定向到 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; }
?>