title: Why isn't this PHP code validating user input?
body: <p>I am creating a form with a validation code. I already know the form works as I'm building off of a previous project by adding the validation code. I am doing this for a class and I followed exactly what the example showed. For whatever reason though, it isn't validating. I don't need someone to tell me how to do my homework, but I could really use a point in the right direction here.</p>
  
  <p>The code below is from my HTML file which, when the form is submitted, passes the data through a PHP file. It's only the validation code in the HTML file that I'm struggling with, so I won't attach the PHP file.</p>
  
  <pre><code>&lt;!Doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8" /&gt;
  &lt;link rel="stylesheet" type="text/css" href="basics.css"/&gt;
  &lt;title&gt;Form Process&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="holder"&gt;
    &lt;?php
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $street=$_POST['street'];
    $city=$_POST['city'];
    $state=$_POST['state'];
    $zip=$_POST['zip'];
    $phone=$_POST['phone'];
    if (empty($fname)) {
      $error_message="You must enter a value for your first name!";
    } else if (empty($lname)) {
      $error_message="You must enter a value for your last name!";
    } else if (empty($street)) {
      $error_message="You must enter a value for your street address!";
    } else if (empty($city)) {
      $error_message="You must enter a value for your city!";
    } else if (empty($state)) {
      $error_message="You must enter a value for your state!";
    } else if (empty($zip)) {
      $error_message="You must enter a value for your zip code!";
    } else if (empty($phone)) {
      $error_message="You must enter a value for your phone number!";
    } else {
      $error_message="You must enter a value!";
    }
  ?&gt;
  &lt;h1&gt;Sign Up Now!&lt;/h1&gt;
  &lt;center&gt;&lt;form action="info_output_includes.php" method="post"&gt;
  &lt;table&gt;
  &lt;tr&gt;&lt;td&gt;First Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="fname" name="fname"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Last Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="lname" name="lname"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Address:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="street" name="street" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;City:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="city" name="city" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;State:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="state" name="state"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Zip Code:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="zip" name="zip" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Phone:&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="phone" name="phone"/&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr &gt;&lt;td &gt;&lt;input type="submit" value="Submit" /&gt;&lt;/td&gt;
  &lt;td class="totheleft"&gt;&lt;input type="reset" value="Clear" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;&lt;/center&gt;
  &lt;br&gt;
  &lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If the validation code were working, it should say (for example) "You must enter a value for your first name!" if the user submitted the form without entering a first name value. Of course, it should basically print an error message if any value is left empty. </p>