title: PHP Form Validation Best Practice
body: <p>This isn't so much of a how do you do something, but more of a best practice question. </p>
  
  <p>I'm building a simple login application for an internal project using the <a href="https://github.com/panique/php-login-advanced%22php-login-advanced%22" rel="nofollow noreferrer">php-advanced-login</a> framework. The way I'm validating the login form, password reset and login via cookie using using a class that is initialized when a user submits the form. The class then validates everything and any errors are returned in an array and shown in the form. </p>
  
  <pre><code>&lt;?php if(isset($_POST['submit_login'])){
  //load class
  }
  &lt;!doctype html&gt;
  //form
  </code></pre>
  
  <p>My questions is, having everything in this class seems like a bit of a mess (it seems like it's harder to maintain than how I use to do it explained further on), it's all in there because there is lots of code re-use. The way I've done it before is just to split my code up into several php files with functions and just include them when needed. Each php file is a lot shorter and easier to maintain in my opinion. I don't use any real advantages of using a class over just methods. </p>
  
  <p>Whats your opinion on this if you've managed to follow my rambling? Should I use a class and have everything together, just use functions, another better way?</p>