How to remain on the same page if error occured?
<p>The following code is simplified to illustrate my question.  This is a page to capture data and it will will post the captured info and pass to another php page for processing.  I'm trying to ensure the required fields are entered but it always go to the calling page regardless there is error.
Can anyone help?</p>

<pre><code>&lt;?php
  if (empty($_POST) === false) {
    $required_field = array('first_name','last_name');
    foreach ($_POST as $key=&gt;$value) {
    if (empty($value) &amp;&amp; in_array($key, $required_field) === true) {
      $errors[] = 'Fields marked with asterisk are required';
      break 1;
      }
    }
  }
?&gt;
&lt;h1&gt;Input Form&lt;/h1&gt;

&lt;?php
  if (empty($errors) === false) {
    echo output_errors($errors);
  }
?&gt;

&lt;form method="POST" action="UpdateDB.php" name="UpdateForm"&gt;
   &lt;input type=text size="19" maxlength="19" name="firstname"&gt;
   &lt;input type=text size="19" maxlength="19" name="lastname"&gt;   
   &lt;input type="submit" value="Submit" &gt;
&lt;/form&gt;
</code></pre>
