title: Printing validation message on the same page in PHP
body: <p>Hi I have this function in handling upload errors.</p>
  
  <pre><code>function error($error, $location, $seconds = 5)
  {
      header("Refresh: $seconds; URL=\"$location\"");
      echo 'Error :' . $error . ' Please correct before proceeding.';
      exit;
  } 
  </code></pre>
  
  <p>Since this is <code>echo</code>'s the message, you know the message shows not in the same page and you need to hit browser back to return to the original content page.</p>
  
  <p>What I wanted is the validation messages to be shown on the same page, so I tried changing the code to following.</p>
  
  <pre><code>function error($error)
  {
      $ErrMsg = 'Error :' . $error . ' Please correct before proceeding.';
  
  } 
  </code></pre>
  
  <p>And later in the form in a table I have something like following to call the massage.</p>
  
  <pre><code>&lt;td&gt;&lt;?php if(!empty($ErrMsg)) echo $ErrMsg; ?&gt;&lt;/td&gt;
  </code></pre>
  
  <p>However this method doesn't seems to be giving me the solution I need, which is to print the validation message on the same page.</p>
  
  <p>Can anyone help?</p>
  
  <p>thanks.</p>