1

Everything works fine except email address. When i post email address to server and just echo it, recieve nothing. Only problem in @ symbol, rest are ok.

angular:

$http({
            method: 'POST',
            url: 'http://______.org/_____.php',
            data: {
                signInSubmitBTN: '',  email: 'joe@g.com'
            }
        }).success(function (data) {
            alert(data); //alert empty when joe@g.com but joeg.com is ok
        });

PHP

if (isset($_POST['signInSubmitBTN'])) {

$email = $_POST["email"];

echo $email;
}

NOTE - already configure app

app.config(function ($httpProvider, $httpParamSerializerJQLikeProvider) {
    $httpProvider.defaults.transformRequest.unshift($httpParamSerializerJQLikeProvider.$get());
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
    })

2 Answers2

3

You need to encode using base64:

signInSubmitBTN: '',  email: window.btoa('joe@g.com')

And don't forget to decode on the server side using atob()

deChristo
  • 1,860
  • 2
  • 17
  • 29
1

Use this code in back end to get POST data back in PHP.

if(isset($_POST)){

  $postdata = file_get_contents("php://input");

 $request = json_decode($postdata);
  echo $request->email;
 }
nidhin
  • 419
  • 1
  • 4
  • 16