title: PHP Form validation, error message output
body: <p>Can anyone with more experience than me take a look at this page and figure out why the php validation isn't working.
  This is the first time I've programmed in PHP, I've run it through PHP lint, there are no fatal errors in the code, just need to get the error messages outputting when the user tries to submit the form.
  The JS validation is working fine, the red error messages are the jQuery validation, so it might be best to turn JS off.</p>
  
  <p>Thanks</p>
  
  <p><a href="http://www.cambrianvacation.co.uk/vpc/register1.php" rel="nofollow">http://www.cambrianvacation.co.uk/vpc/register1.php</a></p>
  
  <p>Edit here's the code
        
  
  <pre><code>//form processing
  //import form info
  //run this code when page submits test with js turned off
   if (isset($_POST["submit"])) {
  $email = $_POST['email'];
  $password = $_POST['password'];
  $confirm_password = $_POST['confirm_password'];
  $myArray = $errors();
  function validate_firstname(){
  //validate here, 
  if(!isset($_POST['firstname'])){
       $errors = print 'Please enter your firstname';
      }
  else if(strlen($_POST['firstname']) &lt;=2){
       $errors = print 'Your firstname must be more than 2 characters';
  }else{//data is fine send to encryption
  
      return $_POST['firstname'];
  };
  };
  
  function validate_lastname(){
  //validate here
  if(!isset($_POST['lastname'])){
       $errors = print 'Please enter your lastname';
      }
  else if(strlen($_POST['lastname']) &lt;=2){
       $errors = print 'Your lastname must be more than 2 characters';
  }else{//data is fine send to encryption
  
      return $_POST['lastname'];
  };
  };
  function validate_username(){
  //validate here
  if(!isset($_POST['username'])){
       $errors = print 'Please enter your username';
      }
  else if(strlen($_POST['username']) &lt;=2){
       $errors = print 'Your username must be more than 2 characters';
  }else{//data is fine send to encryption
  
      return $_POST['username'];
  };
  };      
  
  
  
    function is_valid_email_address($email){
      $qtext = '[^\\x0d\\x22\\xSc\\x80-\\xff]';
      $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
      $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c' .
      '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
      $quoted_pair = '\\x5c[\\x00-\\x7f]';
      $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
      $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
      $domain_ref = $atom;
      $sub_domain = "($domain_ref|$domain_literal)";
      $word = "($atom|$quoted_string)";
      $domain = "$sub_domain(\\x2e$word)*";
      $local_part = "$word(\\x2e$word)*";
      $addr_spec = "$local_part\\x40$domain";
      return preg_match("!^$addr_spec$!", $email)? 1 : 0;
    };
    if (is_valid_email_address($email)){
       $errors = print 'Your email is a valid email address';
    } else{$errors = print 'Please enter a valid email address';
      };
  
  
    function validate_password($password){
      if(!isset($password)){
            $errors = print 'Please provide a password';
      }else if(strlen($password) &lt;=5){
          $errors = print 'Your password must be at least 25 charachters long';
      }   
      else{return $password;}
  };
  
      function confirm_password($confirm_password){
  
          if ($password !== $confirm_password){
               $errors = print 'Please enter the same password as above';
          }else{ $password === $confirm_password;}
              return $confirm_password;
          };
      };
   ?&gt;
  
  &lt;div id="bigwrap"&gt;
          &lt;div id = "space"&gt;&lt;/div&gt;
      &lt;div class="wrapper"&gt;
  
          &lt;div class="content"&gt;
              &lt;div id="form_wrapper" class="form_wrapper"&gt;
  
                  &lt;form class="register active" class="cmxform" action= "regprocess.php"           id="signupForm" class = "ajaxsubmit" method="get"&gt;
                      &lt;fieldset class="ui-widget ui-widget-content ui-corner-all"&gt;
                      &lt;h3 class="font"&gt;REGISTER&lt;/h3&gt;
                      &lt;div class="column"&gt;
                          &lt;div&gt;
                              &lt;label for="cname"&gt;Firstname&lt;/label&gt;
   &lt;input id="cfirstname" name="firstname" type="text" class="required"   minlength="2" /&gt;
  
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;label for="cname"&gt;Username&lt;/label&gt;
   &lt;input id="cusername" name="username" type="text"  class="required"  minlength="5" /&gt;
  
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;label for="cemail"&gt;E-Mail:&lt;/label&gt;
          &lt;input id="cemail" name="email" type="text"  class="required email" /&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="column"&gt;
                          &lt;div&gt;
                              &lt;label for="cname"&gt;Lastname&lt;/label&gt;
   &lt;input id="cname" name="lastname" type="text" class="required" class="ui-state-highlight" minlength="2" /&gt;
  
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;label for="password"&gt;Password:&lt;/label&gt;
          &lt;input id="password" name="password" type="password"  class="required"/&gt;
  
                          &lt;/div&gt;
                          &lt;div&gt;
                              &lt;label for="confirm_password"&gt;Confirm password:&lt;/label&gt;
          &lt;input id="confirm_password" name="confirm_password"   type="password" class="required" /&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="bottom"&gt;
                          &lt;div class="remember"&gt;
  
                          &lt;/div&gt;
                          &lt;input type="submit" value="Register" class= "submit"/&gt; 
                          &lt;a href="index.html" rel="login" class="linkform"&gt;You have an account already? Log in here&lt;/a&gt;
  
                          &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;ul&gt;&lt;?php echo $errors; ?&gt;&lt;/ul&gt;
                  &lt;/fieldset&gt;
                  &lt;/form&gt;
  </code></pre>