title: PHP form does not check other inputs
body: <p>I have made a contact form, however the PHP only checks for 'message' and if thats filled out all other checks are ignored. If its not filled out all other checks work as well.
  Can someone please help me fix my code? Thanks.</p>
  <pre><code>&lt;?php
  $fullName = $customerEmail =  $message = '';
  $errors = array('fullName' =&gt; '', 'customerEmail' =&gt; '', 'message' =&gt; '');
  
  if (isset($_POST['submit'])) {
      $myEmail = &quot;xxxxxxxxxxxxx&quot;;
      $timeStamp = date(&quot;dd/M/YY HH:i:s&quot;);
      $body = &quot;&quot;;
  
      $fullName = $_POST['fullName'];
      $customerEmail = $_POST['customerEmail'];
      $chosenSubject = $_POST['subject'];
      $message = $_POST['message'];
  
      $body .= &quot;From: &quot; . $fullName . &quot; at $timeStamp&quot; . &quot;\r\n&quot;;
      $body .= &quot;Email: &quot; . $customerEmail . &quot;\r\n&quot;;
      $body .= &quot;Message: &quot; . $message . &quot;\r\n&quot;;
  
      if (empty($fullName)) {
          $errors['fullName'] = &quot;Full name is required. &lt;br&gt;&quot;;
      } else {
          if (!preg_match(&quot;/^([a-zA-Z' ]+)$/&quot;, $fullName)) {
              $errors['fullName'] = &quot;Your name must be a valid name.&quot;;
          }
          
      }
  
      if (empty($customerEmail)) {
          $errors['customerEmail'] = &quot;An email is required. &lt;br&gt;&quot;;
      } else {
          if (!filter_var($customerEmail, FILTER_VALIDATE_EMAIL)) {
              $errors['customerEmail'] = &quot;Email must be a valid email address.&quot;;
          }
      }
  
      if (empty($message)) {
          $errors['message'] = &quot;A message is required.&quot;;
      } 
      
      else {
          mail($myEmail, $chosenSubject, $body);
          header(&quot;Location: public/mail_sent.php&quot;);
      }
  }
  ?&gt;
  </code></pre>