title: Save form data using AJAX to PHP
body: <p>How can I save the form data in a file or a local db (maybe using AJAX) which send the data via form action to an external db?</p>
  
  <p>The source code for my form is here: <a href="http://jsbin.com/ojUjEKa/1/edit" rel="nofollow">http://jsbin.com/ojUjEKa/1/edit</a></p>
  
  <p>What changes (if any) should I make to the code?</p>
  
  <pre><code>EDIT:
  </code></pre>
  
  <p>Right. So I'm able to store the data into localStorage using AJAX and want to send the data stored across to a file called backend.php. Here's my html file: <a href="http://jsbin.com/iSorEYu/1/edit" rel="nofollow">http://jsbin.com/iSorEYu/1/edit</a></p>
  
  <p>and here's my backend.php file: <a href="http://jsbin.com/OGIbEDuX/1/edit" rel="nofollow">http://jsbin.com/OGIbEDuX/1/edit</a></p>
  
  <p>The AJAX is working absolutely fine to store the fields in localStorage but things go wrong when it tries to send the data across to backend.php. I receive the following errors:</p>
  
  <pre><code> [24-Jan-2014 08:40:34 America/Chicago] PHP Notice:  Undefined index: data in /home4/private/public_html/marketer/backend.php on line 7
   [24-Jan-2014 08:40:34 America/Chicago] PHP Warning:  Invalid argument supplied for foreach() in /home4/private/public_html/marketer/backend.php on line 10
   [24-Jan-2014 08:40:58 America/Chicago] PHP Notice:  Undefined index: data in /home4/private/public_html/marketer/backend.php on line 7
   [24-Jan-2014 08:40:58 America/Chicago] PHP Warning:  Invalid argument supplied for foreach() in /home4/private/public_html/marketer/backend.php on line 10
  </code></pre>
  
  <p>What's the issue here?</p>