title: PHP Form Validation Showing Errors Before Submission
body: <p>I am working on making a PHP and MySQL application for practicing my new-found love for programming. I have a login script; the HTML form is as follows:</p>
  
  <pre><code>&lt;form action="&lt;?php echo $_SERVER["PHP_SELF"]; ?&gt;" method="post"&gt;
  
              Username:
  
                  &lt;input type="text" name="username" maxlength="60"&gt;&lt;br /&gt;
  
  
  
              Password:
  
                  &lt;input type="password" name="password" maxlength="60"&gt;&lt;br /&gt;
  
  
  
             Confirm Password:
  
                  &lt;input type="password" name="password_confirm" maxlength="60"&gt;&lt;br /&gt;
  
  
                  &lt;input type="submit" name="submit" value="Register"&gt;&lt;br /&gt;
  
           &lt;/form&gt;
  </code></pre>
  
  <p>This continues into the PHP form validator:</p>
  
  <pre><code>&lt;?php
  
  $username_original = $_POST["username"];
  $password_original = $_POST["password"];
  $password_confirm_original = $_POST["password_confirm"];
  
         //This makes sure they did not leave any fields blank 
  
  function FieldComplete($user, $password, $password_confirm) {
      if (!isset($user, $password, $password_confirm) &amp;&amp;
          $user &amp;&amp; $password &amp;&amp; $password_confirm == "" || " ") {
          $field_confirm = false;
      } else {
          $field_confirm = true;
      }
  
  
      if ($field_confirm == true) {
          echo "";
      } else {
          echo "You did not complete all the required fields.";
      }
  }
  
  FieldComplete($username_original, $password_original, $password_confirm_original);
  
  ?&gt;
  </code></pre>
  
  <p>I realize that making a function for this might seem a little useless, but it was as close as I got to the result I wanted.</p>
  
  <p>However, this code displays the error "You did not complete all the required fields." on loading of the page. I only want that error to display if they have pressed the register button and still have a blank field.</p>
  
  <p>Any advice or help is greatly appreciated. Thanks StackOverflow community!</p>