I have a javascript code making an Ajax call to a php script. The request is sent and seems ok when I look at Chrome network tab:
Request URL:http://localhost/site/current/inscription/ Request
Method:POST Status Code:200 OK
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:55
Content-Type:application/x-www-form-urlencoded
Cookie:[...]
Host:localhost
Origin:http://localhost
Referer:http://localhost/site/current/
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.60 Safari/537.1
X-CSRF-Token:undefined
X-Requested-With:XMLHttpRequest
Form Data:
nomClient:bob
emailClient:bob@bob.com
But the PHP script does not find the form data:
if (isset($POST['emailClient']))
returns false.
The PHP script works ok when I use GET and call it from the browser URL bar directly.
What could be the problem?
Use
if (isset($_POST['emailClient']))instead.$POSTis (probably)nulland thus false, you forgot the underscore.docs