title: AngularJS HTTP post to PHP and undefined
body: <p>I have a form with the tag <code>ng-submit="login()</code></p>
  
  <p>The function gets called fine in javascript.</p>
  
  <pre><code>function LoginForm($scope, $http)
  {
      $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
  
      $scope.email    = "fsdg@sdf.com";
      $scope.password = "1234";
  
      $scope.login = function()
      {
          data = {
              'email' : $scope.email,
              'password' : $scope.password
          };
  
          $http.post('resources/curl.php', data)
          .success(function(data, status, headers, config)
          {
              console.log(status + ' - ' + data);
          })
          .error(function(data, status, headers, config)
          {
              console.log('error');
          });
      }
  }
  </code></pre>
  
  <p>I am getting a 200 OK response back from the PHP file, however, the returned data is saying that <code>email</code> and <code>password</code> are undefined. This is all the php I have</p>
  
  <pre><code>&lt;?php
  $email = $_POST['email'];
  $pass  = $_POST['password'];
  echo $email;
  ?&gt;
  </code></pre>
  
  <p>Any idea why I am getting undefined <code>POST</code> values?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I wanted to point out since this seems to be a popular question (yet it is old), <code>.success</code> and <code>.error</code> have been deprecated and you should use <code>.then</code> as @James Gentes pointed out in the commments</p>