title: PHP Parse error: syntax error, unexpected end of file
body: <p>I am very new to PHP and somehow got thrown into an advanced level course. My instructor will not offer any help since it is an advanced course. I will post my code below in hopes that someone can at least point me in the right direction for a fix. This is only the first part of the assignment, but not worth going any further if I cannot get this part to work. I believe I have check all the braces and quotes, but I sure could have missed something or ?????. </p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style&gt;
  .error {color: #FF0000;}
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  // define variables and set to empty values
  $name1Err = $name2Err = $dobErr = $stateErr = $zipErr = "";
  $name1 = $name2 = $dob = $state = $zip = "";
  
  if ($_SERVER["REQUEST_METHOD"] == "POST")
  {
     if (empty($_POST["name1"]))
       {$name1Err = "First Name is required";}
     else
       {
       $name1 = test_input($_POST["name1"]);
       // check if name only contains letters and whitespace
       if (!preg_match("/^[a-zA-Z ]*$/",$name1))
         {
         $name1Err = "Only letters and white space allowed";
         }
       }
  
     if (empty($_POST["name2"]))
       {$name2Err = "Name is required";}
     else
       {
       $name2 = test_input($_POST["name2"]);
       // check if name only contains letters and whitespace
       if (!preg_match("/^[a-zA-Z ]*$/",$name2))
         {
         $name2Err = "Only letters and white space allowed";
         }
       }
  
     if (empty($_POST["dob"]))
       {$dobErr = "Date Of Birth is required";}
     else
       {
       $dob = test_input($_POST["dob"]);
       // check if date of birth format is valid
       if (!preg_match("/^[0-9]{1,2}\-[0-9]{1,2}\-[0-9]{4}$/",$dob))
         {
         $dobErr = "Invalid date format";
         }
       }
  
     if (empty($_POST["state"]))
       {$stateErr = "2 Digit State Abbreviation is required";}
     else
       {
       $state = test_input($_POST["state"]);
       // match two uppercase letters with definite (one or more) whitespace on either side)
       if (!preg_match("/\s+[A-Z]{2}\s+/ ",$state))
         {
         $stateErr = "Invalid State Abbreviation";
     }
       }
  
     if (empty($_POST["zip"]))
       {$zipErr = "Zip Code is required";}
     else
       {
       $zip = test_input($_POST["zip"]);
       // Validates Zip Code (5 digits plus optional -4)
       if (!preg_match("^\d{5}(-\d{4})?$",$zip))
         {
         $zipErr = "Only letters and white space allowed";
         }
       }
  
  
  function test_input($data)
  {
       $data = trim($data);
       $data = stripslashes($data);
       $data = htmlspecialchars($data);
       return $data;
  }
  ?&gt;
  
  &lt;p&gt;&lt;span class="error"&gt;* required field.&lt;/span&gt;&lt;/p&gt;
  &lt;form method="post" action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;"&gt;
     First Name: 
       &lt;input type="text" name="name1"&gt;
     &lt;span class="error"&gt;* &lt;?php echo $name1Err;?&gt;&lt;/span&gt;
     &lt;br&gt;&lt;br&gt;
     Last Name: 
     &lt;input type="text" name="name2"&gt;
     &lt;span class="error"&gt;* &lt;?php echo $name2Err;?&gt;&lt;/span&gt;
     &lt;br&gt;&lt;br&gt;
     Date Of Birth: 
     &lt;input type="text" name="dob"&gt;
     &lt;span class="error"&gt;&lt;?php echo $dobErr;?&gt;&lt;/span&gt;
     &lt;br&gt;&lt;br&gt;
     State: 
       &lt;input type="text" name="state"&gt;
     &lt;span class="error"&gt;* &lt;?php echo $stateErr;?&gt;&lt;/span&gt;
     &lt;br&gt;&lt;br&gt;
     Zip Code: 
     &lt;input type="text" name="zip"&gt;
     &lt;span class="error"&gt;* &lt;?php echo $zipErr;?&gt;&lt;/span&gt;
     &lt;br&gt;&lt;br&gt;
     &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;?php
  echo "&lt;h2&gt;Your Input:&lt;/h2&gt;";
  echo $name1;
  echo "&lt;br&gt;";
  echo $name2;
  echo "&lt;br&gt;";
  echo $dob;
  echo "&lt;br&gt;";
  echo $state;
  echo "&lt;br&gt;";
  echo $zip;
  ?&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>