title: Create error pages from search php script
body: <p>Is it possible to change my search script to direct the client to a different page if there is an error?</p>
  
  <p>Instead of having a text appear "No result have been found!", I would like them to be directed to search_error1.php.</p>
  
  <p>Instead of having a text appear "You have not entered the search field", I would like them to be directed to search_error2.php.</p>
  
  <pre><code>&lt;?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, &lt;a     href="javascript:history.back(1)"&gt;Go back&lt;/a&gt;.';}
  
  }
  
  if (!empty($error)) { echo $error; } 
  
  ?&gt;
  </code></pre>