title: AngularJS and PHP entering blank rows in database
body: <p>I'm trying to figure out why my data is not being collected by my PHP files.
  This is my index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" ng-app="gemStore"&gt;
  &lt;head&gt;
      &lt;meta http-equiv='Content-Type':'application/x-www-form-urlencoded; charset=UTF-8' /&gt;
      &lt;title&gt;Angular&lt;/title&gt;
      &lt;link rel="stylesheet" href="css/bootstrap.min.css"&gt;
      &lt;link rel="stylesheet" href="css/style.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div ng-controller="custController"&gt;
          &lt;form&gt;
              First Name: &lt;input type="text" ng-model="firstname"&gt;&lt;br&gt;
              Last Name: &lt;input type="text" ng-model="lastname"&gt;&lt;br&gt;
              Choose Username: &lt;input type="text" ng-model="username"&gt;&lt;br&gt;
              Choose Password: &lt;input type="text" ng-model="password"&gt;&lt;br&gt;
              Address 1: &lt;input type="text" ng-model="address1"&gt;&lt;br&gt;
              Address 2: &lt;input type="text" ng-model="address2"&gt;&lt;br&gt;
              City: &lt;input type="text" ng-model="city"&gt;&lt;br&gt;
              State: &lt;input type="text" ng-model="state"&gt;&lt;br&gt;
              Zip: &lt;input type="number" ng-model="zip"&gt;&lt;br&gt;
              &lt;input type="button" value="Submit" ng-click="insertdata()"&gt;&lt;br&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
      &lt;script src="js/angular.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/script.js"&gt;&lt;/script&gt;
      &lt;script src="js/products.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my script.js</p>
  
  <pre><code>(function(){
      var app = angular.module('gemStore', ['store-products']);
      app.controller('StoreController', ['$http', function($http){
          var store = this;
          store.products = [];
          $http.get('/store-products.json').success(function(data){
              store.products = data;
          });
      }]);
  
      app.controller('custController', function($scope,$http){
          $scope.insertdata = function(){
              $http.post('insert.php',{'firstname':$scope.firstname,'lastname':$scope.lastname,'address1':$scope.address1,'address2':$scope.address2, 'city':$scope.city,'state':$scope.state,'zip':$scope.zip,'username':$scope.username,'password':$scope.password})
              .success(function(data,status,headers,config){
                  console.log('data inserted successfully. First Name: ' + $scope.firstname);
              });
          }
      });
  })();
  </code></pre>
  
  <p>And finally my PHP file</p>
  
  <pre><code>&lt;?php
  
      $data = json_decode(file_get_contents("php://input"));
  
      $firstname = mysql_real_escape_string($data-&gt;firstname);
      $lastname = mysql_real_escape_string($data-&gt;lastname);
      $username = mysql_real_escape_string($data-&gt;username);
      $address1 = mysql_real_escape_string($data-&gt;address1);
      $address2 = mysql_real_escape_string($data-&gt;address2);
      $city = mysql_real_escape_string($data-&gt;city);
      $state = mysql_real_escape_string($data-&gt;state);
      $zip = mysql_real_escape_string($data-&gt;zip);
      $password = mysql_real_escape_string($data-&gt;password);
  
      mysql_connect("localhost","root","");
      mysql_select_db("mydatabase");
      mysql_query("INSERT INTO users (`firstname`, `lastname`, `username`, `password`, `address1`, `address2`, `city`, `state`, `zip`)VALUES('" . $firstname . "','" . $lastname . "','" . $username . "','" . $password . "','" . $address1 . "','" . $address2 . "','" . $city . "','" . $state . "','" . $zip . "')");
  
  ?&gt;
  </code></pre>
  
  <p>I am thinking it has something to do with headers, but I'm not sure where I should add it or what needs to be changed.  Any help would be appreciated.  Thanks.</p>
  
  <p>Also, I am using angular 1.3.16, but I doubt that makes a difference.</p>