2016-11-23 5 views
1

メールアドレス以外はすべて正常に動作します。私は電子メールアドレスをサーバーに投稿し、それをエコーすると、何も受信しません。 @ symbol、restの問題のみOKです。

角度:

$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 -すでにアンにあなたが必要とするアプリ

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'; 
    }) 

答えて

3

を設定BASE64を使用してコード:

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

とバックPHPでPOSTデータを取得するために、バックエンドでこのコードを使用しatob()

+0

ありがとうございます。別の質問encodeURIComponent(電子メール)、これはまたこれのための代替かどうかです。 –

+0

次のURLをご覧ください:http://stackoverflow.com/questions/10267597/url-encode-vs-base64-encoding-usages – deChristo

1

を使用して、サーバー側でデコードすることを忘れないでください。

if(isset($_POST)){ 

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

$request = json_decode($postdata); 
    echo $request->email; 
} 
関連する問題