title: PHP show error message on ajax submission
body: <p>I am php beginner. I am submitting a form using ajax call. So after submission of the form user stay on the same page and do not go to reserve_seat.php since ajax call.</p>
  
  <pre><code>&lt;form action="reserve_seat.php" method="POST"&gt;
  First name:&lt;br&gt;
  &lt;input type="text" name="name" value="Mickey"&gt;
  &lt;br&gt;
  Email:&lt;br&gt;
  &lt;input type="text" name="email" value="Mouse"&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt; 
  
  &lt;script&gt;
        $(function () {
          $('form').on('submit', function (e) {
            e.preventDefault();
            $.ajax({
              type: 'post',
              url: 'reserve_seat.php',
              data: $('form').serialize(),
              success: function () {
                alert('form was submitted');
              }
            });
          });
        });
      &lt;/script&gt;
  </code></pre>
  
  <p>Now after submission of the form I do some validation for email and if the email validation fail I want to show an error message above the form. May be insert a div showing that email not valid. How can I do that? My validation code below</p>
  
  <pre><code>    if( !empty($_POST['name']) &amp;&amp; !empty($_POST['email'])){
          $name = $_POST['name'];
          $email = $_POST['email'];
  
          if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
          $insert = 'INSERT into reservation(name,email) VALUES ("'.$name.'", "'.$email.'")';
          mysql_query($insert);
           } else {
          //need help here to show error message 
  }
      }
  </code></pre>