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: '[email protected]'
            }
        }).success(function (data) {
            alert(data); //alert empty when [email protected] 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 Answers 2

3

You need to encode using base64:

signInSubmitBTN: '',  email: window.btoa('[email protected]')

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. another question encodeURIComponent(email), is it also an alternative for this or not.
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;
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.