title: HTML form error handling
body: <p>I found on another question (<a href="https://stackoverflow.com/questions/11237655/display-form-validation-errors-next-to-each-field">Display form validation errors next to each field</a>) the following code:</p>
  
  <pre><code> &lt;?php
          $error = array(
              "name" =&gt; "",
              "email" =&gt; "",
              "subject" =&gt; "",
              "message" =&gt; ""
          );
      ?&gt;
  
      &lt;?php
          if (empty($_POST["email"]))
              $error["email"] = "Email is required!";
          elseif (!isEmail($_POST["email"]))
              $error["email"] = "Not a Valid Email!";
      ?&gt;
  </code></pre>
  
  <p>If there are no errors, it would be empty and the user doesn't see the error message. </p>
  
  <p>In your Forms Code, you need to just update this way:</p>
  
  <pre><code>    &lt;small class="errorText"&gt;&lt;?php echo $error["name"]; ?&gt;&lt;/small&gt;
      &lt;small class="errorText"&gt;&lt;?php echo $error["email"]; ?&gt;&lt;/small&gt;
  </code></pre>
  
  <p>where in the backend, the <code>$error["email"]</code> would have either <code>"This field is required"</code> or <code>"Not a valid email address!"</code>.</p>
  
  <p>I tried to apply this to my code:</p>
  
  <p>so I pasted the php section above in email.php and I updated my form like so:</p>
  
  <pre><code>    &lt;form id="contacts-form" method="post" action="email.php" target="myiframe" &gt;
         &lt;fieldset&gt;
         &lt;div class="field"&gt;
            &lt;label&gt;Your E-mail:&lt;/label&gt;
            &lt;input type="email" name="email" value=""/&gt;
            &lt;small class="errorText"&gt;&lt;?php echo $error["email"]; ?&gt;&lt;/small&gt;
         &lt;/div&gt;
         ...
  </code></pre>
  
  <p>now I get an error saying $error is not defined. Please bare in mind that Im new to php/HTML design and I am trying to learn by example</p>
  
  <p>Thanks</p>