title: Simple PHP Post-Redirect-Get code example
body: <p>I have found many sites that describes PRG, but no simple PHP code example.</p>
  
  <hr>
  
  <p>Here's what I implemented:</p>
  
  <ol>
  <li>The <code>form.php</code> has an action: <code>validate.php</code>.</li>
  <li>The <code>validate.php</code> is never seen by the user; if validates all <code>$_GET</code> and, if valid writes it to database and generates the HTML of a confirmation page / if not valid, it generates the HTML of an error page explaining what is wrong. </li>
  <li>Whichever HTML is generated get stored in a <code>$_SESSION</code> variable and then <code>validate.php</code> calls <code>header('Location: &lt;as appropriate&gt;);</code>.</li>
  <li>The <code>submitted.php</code> of <code>invalid_input.php</code> (in case the user reads the URL) consists only of <code>echo $_SESSION['form_html'];</code>.</li>
  </ol>
  
  <p>That seems to me like protection against both page reload and back button problems.</p>
  
  <p>Did I goof by trying to reinvent the wheel?</p>