title: jQuery AJAX form using mail() PHP script sends email, but POST data from HTML form is undefined
body: <p>Thanks for taking the time to look, guys. I'm creating a pretty basic AJAX contact form using jQuery. The email sends, but upon opening the email there is no POST data, so I just get the strings I defined in the PHP script. On my phone's email client, the content of the email literally says 'undefined'. I've tried adding different types of header data to no avail, and a number of variations on the PHP mail() function. </p>
  
  <p>I am more than willing to adopt an easier solution for a simple AJAX form, so thanks in advance for any new approaches. </p>
  
  <p>Here is the form:
      </p>
  
  <pre><code>   &lt;section id="left"&gt;
        &lt;label for="form_name"&gt;Name&lt;/label&gt;
        &lt;input name="form_name" id="form_name" type="text" &gt;
  
        &lt;label for="form_email"&gt;Email&lt;/label&gt;
        &lt;input name="form_email" id="form_email" type="email" &gt;
     &lt;/section&gt;
  
     &lt;section id="right"&gt;
        &lt;label for="form_msg"&gt;Message&lt;/label&gt;
        &lt;textarea name="form_msg" id="form_msg"&gt;&lt;/textarea&gt;
        &lt;input id="submit" class="button" name="submit" type="submit" value="Send"&gt;
     &lt;/section&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>The jQuery AJAX:</p>
  
  <pre><code>$(function() {
      $("#contact .button").click(function() {
          var name = $("#form_name").val();
          var email = $("#form_email").val();
          var text = $("#msg_text").val();
          var dataString = 'name='+ name + '&amp;email=' + email + '&amp;text=' + text;
  
          $.ajax({
              type: "POST",
              url: "email.php",
              data: dataString,
              success: function(){
              $('.success').fadeIn(1000);
              }
          });
  
          return false;
      });
  });
  </code></pre>
  
  <p>The PHP script (external file 'email.php'):</p>
  
  <pre><code>&lt;?php
  if($_POST){
      $name = $_POST['form_name'];
      $email = $_POST['form_email'];
      $message = $_POST['form_msg'];
  
  //send email
      mail("email@gmail.com", "This is an email from:" .$email, $message);
  }
  ?&gt;
  </code></pre>