title: PHP contact form not validating or sending
body: <p>Ok...so I grabbed this PHP contact form from a combination of a few different websites and from a predecessor. I've been wrestling with it for hours and can't figure it out. </p>
  
  <p><strong>In all fairness, know that PHP is not my strong suit, at all</strong>, (I'm a client-side programmer). Here's the code below, please help if you can. Thank you!</p>
  
  <p><strong>Here are some of the error messages I've seen:</strong></p>
  
  <p>The most recent:
  *Parse error: syntax error, unexpected T_IF in /home/[...] on line 11*</p>
  
  <p>Before, here was the error message, but I believe I fixed the "blank field" part:</p>
  
  <p><em>It appears that you left a blank field.</em></p>
  
  <p><em>Please make sure you fill in your full name, email address, subject, and details.
  Click the back arrow to return to the contact form.</em></p>
  
  <p><em>From:... List:; syntax illegal for recipient addresses</em></p>
  
  <p><em>Reply-To:... List:; syntax illegal for recipient addresses</em></p>
  
  <p><em>X-Mailer:... List:; syntax illegal for recipient addresses</em>  </p>
  
  <p><em>Thank you, [name], for contacting us!</em></p>
  
  <p><strong>Here's the HTML</strong></p>
  
  <pre><code>&lt;form action="contactus.php" method="post" class="create"&gt;
       &lt;fieldset&gt;
      &lt;legend align="center"&gt;Please fill out details below and click "Submit"&lt;/legend&gt;
      &lt;div&gt;
       &lt;label for="fullname" class="fixedwidth"&gt;Full Name&lt;/label&gt;
       &lt;input type="text" name="fullname" id="fullname" class="input2"/&gt;
      &lt;/div&gt;&lt;br/&gt;
      &lt;div&gt;
       &lt;label for="email" class="fixedwidth"&gt;Email&lt;/label&gt;
       &lt;input type="text" name="email" id="email" class="input2"/&gt;
      &lt;/div&gt;&lt;br/&gt;
        &lt;div&gt;
       &lt;label for="subject" class="fixedwidth"&gt;Subject&lt;/label&gt;
       &lt;input type="text" name="subject" id="subject" class="input2"/&gt;
      &lt;/div&gt;&lt;br/&gt;
      &lt;div&gt;
      &lt;label for="details" class="fixedwidth"&gt;Body&lt;/label&gt;
       &lt;textarea id="details" name="details" cols="62" rows="20"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="buttonarea"&gt;
          &lt;input type="submit" name="submit" id="submit" value="Submit"/&gt;
      &lt;/div&gt;
  
      &lt;/fieldset&gt;
     &lt;/form&gt;
  </code></pre>
  
  <p><strong>...and here's the contactus.php file:</strong></p>
  
  <pre><code>&lt;?php
  
   $fullname = $_POST['fullname'];
   $subject = $_POST['subject'];
   $details = $_POST['details'];
   $email = $_POST['email'];
  
  //*** Function to check email address */
   function checkemail($email) { 
    $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)@[a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z]{2,3})$/'
     if (eregi($regex ,$email))
     { 
      return true; 
     } 
      else
     { 
      return false; 
     } 
   }
  
  //*** Check to see if the email address is valid */
   else if (checkemail($email) == false) { 
    echo "&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;center&gt;It appears that you have entered an invalid email address.&lt;br/&gt; Please check your email again.&lt;/p&gt;";
   }
  
  //*** Mail Processing */
   if ($_POST['submit']) {
   //Check for blank fields
    if ($fullname !== "" &amp;&amp; $email !== "" &amp;&amp; $subject !== "" &amp;&amp; $details !== "") {
     echo "&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;center&gt;It appears that you left a blank field.&lt;br/&gt; 
     Please make sure you fill in your full name, email address, subject, and details.&lt;br/&gt;
     Click the back arrow to return to the contact form.&lt;/p&gt;";
    }
  
  //*** Send Mail**/
   $to = 'sgraffito22@gmail.com';
   $fullname = $_POST['fullname'];
   $subject = $_POST['subject'];
   $details = $_POST['details'];
  
   $headers = 'From: '.$email."\r\n".
   'Reply-To: '.$email."\r\n" .
   'X-Mailer: PHP/' . phpversion();
  
   mail($to, $fullname, $subject, $details, $headers);
   echo "&lt;br&gt;&lt;br&gt;&lt;p&gt;&lt;center&gt;Thank you, $fullname, for contacting us!&lt;/p&gt;&lt;br&gt;&lt;br&gt;";
  
  }
  
  ?&gt; 
  </code></pre>