title: Contact form with anti-spam field, PHP or JS issue
body: <p>I have a bootstrap contact form that I added a simple math equation to prevent spam mail. The form is using a contact_me.js to process the form and call the contact_me.php file to validate and send the email. It is also using jqBootstrapValidation.js to validate the form. I used a basic bootstrap template and modified the template for my site, so I did not create the actual form or php (or js).</p>
  
  <p>The form sends emails just fine, but the "human" math equation field that I added is not functioning, as it sends the email regardless if the math answer is correct or not. I know very little of PHP or JS, but I know HTML and CSS quite well - so I know the issue is with the PHP or JS. Can anyone help with what I need to update to fix the issue?</p>
  
  <p>HTML form code:</p>
  
  <pre><code>&lt;div class="form-group col-xs-12 floating-label-form-group controls"&gt;
          &lt;label&gt;Email Address&lt;/label&gt;
          &lt;input type="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address."&gt;
          &lt;p class="help-block text-danger"&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row control-group"&gt;
      &lt;div class="form-group col-xs-12 floating-label-form-group controls"&gt;
          &lt;label&gt;Phone Number&lt;/label&gt;
          &lt;input type="tel" class="form-control" placeholder="Phone Number" id="phone" required data-validation-required-message="Please enter your phone number."&gt;
          &lt;p class="help-block text-danger"&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row control-group"&gt;
      &lt;div class="form-group col-xs-12 floating-label-form-group controls"&gt;
          &lt;label&gt;Message&lt;/label&gt;
          &lt;textarea rows="5" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."&gt;&lt;/textarea&gt;
          &lt;p class="help-block text-danger"&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row control-group"&gt;
      &lt;div class="form-group col-xs-12 floating-label-form-group controls"&gt;
          &lt;label&gt;Human&lt;/label&gt;
          &lt;input type="text" class="form-control" placeholder="2 + 3 = ?" id="human" required data-validation-required-message="Please solve math equation to prove you are human"&gt;
          &lt;p class="help-block text-danger"&gt;&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
   &lt;br&gt;
  &lt;div id="success"&gt;&lt;/div&gt;
  &lt;div class="row"&gt;
      &lt;div class="form-group col-xs-12"&gt;
          &lt;button type="submit" class="btn btn-success btn-lg"&gt;Send&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Contact_Me.php code:</p>
  
  <pre><code>&lt;?php
  // Check for empty fields
  if(empty($_POST['name'])        ||
  empty($_POST['email'])      ||
  empty($_POST['phone'])      ||
  empty($_POST['message'])    ||
  empty($_POST['human'])  ||
  !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
  {
  echo "No arguments Provided!";
  return false;
  }
  
  //Check if simple anti-bot test is correct
  if ($human !== 5) {
     $errHuman = 'Your anti-spam is incorrect';
  }   
  
  $name = $_POST['name'];
  $email_address = $_POST['email'];
  $phone = $_POST['phone'];
  $message = $_POST['message'];
  $message = $_POST['human'];
  
  // Create the email and send the message
  $to = 'info@mysite.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
  $email_subject = "Portfolio Website Message:  $name";
  $email_body = "You have received a new message from your portfolio website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
  $headers = "From: noreply@mysite.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
  $headers .= "Reply-To: $email_address"; 
  mail($to,$email_subject,$email_body,$headers);
  return true;            
  ?&gt;
  </code></pre>
  
  <p>Contact_me.js code:</p>
  
  <pre><code>$(function() {
  
  $("input,textarea").jqBootstrapValidation({
      preventSubmit: true,
      submitError: function($form, event, errors) {
          // additional error messages or events
      },
      submitSuccess: function($form, event) {
          // Prevent spam click and default submit behaviour
          $("#btnSubmit").attr("disabled", true);
          event.preventDefault();
  
          // get values from FORM
          var name = $("input#name").val();
          var email = $("input#email").val();
          var phone = $("input#phone").val();
          var message = $("textarea#message").val();
          var human = $("textarea#human").val();
          var firstName = name; // For Success/Failure Message
          // Check for white space in name for Success/Fail message
          if (firstName.indexOf(' ') &gt;= 0) {
              firstName = name.split(' ').slice(0, -1).join(' ');
          }
          $.ajax({
              url: "././mail/contact_me.php",
              type: "POST",
              data: {
                  name: name,
                  phone: phone,
                  email: email,
                  message: message,
                  human: human
              },
              cache: false,
              success: function() {
                  // Enable button &amp; show success message
                  $("#btnSubmit").attr("disabled", false);
                  $('#success').html("&lt;div class='alert alert-success'&gt;");
                  $('#success &gt; .alert-success').html("&lt;button type='button' class='close' data-dismiss='alert' aria-hidden='true'&gt;&amp;times;")
                      .append("&lt;/button&gt;");
                  $('#success &gt; .alert-success')
                      .append("&lt;strong&gt;Your message has been sent. &lt;/strong&gt;");
                  $('#success &gt; .alert-success')
                      .append('&lt;/div&gt;');
  
                  //clear all fields
                  $('#contactForm').trigger("reset");
              },
              error: function() {
                  // Fail message
                  $('#success').html("&lt;div class='alert alert-danger'&gt;");
                  $('#success &gt; .alert-danger').html("&lt;button type='button' class='close' data-dismiss='alert' aria-hidden='true'&gt;&amp;times;")
                      .append("&lt;/button&gt;");
                  $('#success &gt; .alert-danger').append("&lt;strong&gt;Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
                  $('#success &gt; .alert-danger').append('&lt;/div&gt;');
                  //clear all fields
                  $('#contactForm').trigger("reset");
              },
          })
      },
      filter: function() {
          return $(this).is(":visible");
      },
  });
  
  $("a[data-toggle=\"tab\"]").click(function(e) {
      e.preventDefault();
      $(this).tab("show");
  });
  });
  
  // When clicking on Full hide fail/success boxes
  $('#name').focus(function() {
  $('#success').html('');
  });
  </code></pre>
  
  <p>The jqBootstrapValidation.js is a plugin for automating validation on Bootstrap forms and is located at: <a href="http://ReactiveRaven.github.com/jqBootstrapValidation/" rel="nofollow">http://ReactiveRaven.github.com/jqBootstrapValidation/</a></p>