title: Passing formdata from Phonegap to PHP with JSON
body: <p>I am developing an app in phonegap, and I am trying to pass formdata from phonegap to a remote server with jquery and json and save it to the mysql database.
  I have never used json before, and I am really uncertain of how to recieve and parse this data on the server.</p>
  
  <p>Could anyone help me write a simple php script to handle this?</p>
  
  <p>This is the form and jquery I am using to send data:</p>
  
  <pre><code>&lt;form method="post" id="infoForm"&gt;
         &lt;input type="text" name="first_name" id="first_name" value="" placeholder="First Name"  /&gt;
         &lt;input type="text" name="last_name" id="last_name" value="" placeholder="Last Name"  /&gt;   
         &lt;input type="text" name="email" id="email" value="" placeholder="Email"  /&gt;
        &lt;button type="submit"&gt;Submit&lt;/button&gt; 
  &lt;/form&gt;
  
  $('#infoForm').submit(function() {
  
      var postTo = 'http://siteurl.com';
  
      $.post(postTo,({first_name: $('[name=first_name]').val(), last_name: $('[name=last_name]').val(), email: $('[name=email]').val()}),
      function(data) {
          alert(data);
          if(data != "") {
              // do something
          } else {
              // couldn't connect
          }        
          },'json');
      return false;
  });
  </code></pre>
  
  <p>I have been trying to find a solution for hours without any result.</p>
  
  <p>Thank you!</p>