title: How do i save PHP form input in MySQL database using same script as form input and validation
body: <p>I have a registration-form page that doubles as the validation script. Everything seems to work fine up to the point where the form input is validated. 
  But when the form input is supposed to be saved in the database, PHP reloads 
  the script as if there's still an error with one of the inputs. 
  Once, I placed </p>
  
  <pre><code>if(count($errors) &lt; 1) 
  </code></pre>
  
  <p>outside of </p>
  
  <pre><code>if($_SERVER["REQUEST_METHOD"] == "POST")
  </code></pre>
  
  <p>for a change. It naturally saved the form default input in the database. Which isn't safe. So I placed the snippet back in it's original place.
  I believe it should work based on the examples I saw in google results. Mine just keeps running in a loop. </p>
  
  <p>I've posted the script on <a href="https://gist.github.com/aowasiu/e4f7462af25b6935d4ab" rel="nofollow">Github Gist</a> so maybe someone spots something I might have missed.</p>