|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-05 15:55 UTC] j-spam at starline dot ee
Description: ------------ $_POST is not populated, however $HTTP_RAW_POST_DATA is. lighttpd 1.3.5 using cgi (not fcgi) CGI-PHP5 5.0.3 Firefox 1.0 Reproduce code: --------------- $_POST: <?php print_r($_POST); ?><br> $HTTP_RAW_POST_DATA: <?php print_r($_HTTP_RAW_POST_DATA); ?><br><br> <form action="<?=$_SERVER["PHP_SELF"] ?>" method="post"> <textarea name="duh"><?=$_POST["duh"];?></textarea> <input type="submit" /> </form> Actual result: -------------- $_POST: Array ( ) $HTTP_RAW_POST_DATA: bla=asdf&duh=eeca%0D%0Aasdf%0D%0Aasdf PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
I run into the same problem with my ajax application. When using a XMLHTTPRequest instance I need to provide the data in the following way: key=value&anotherkey=anothervalue So each key/value pair is separated by "&". Additionally I need to define the correct request header which must be set after opening the connection and before sending the request: var postData = "key=value&anotherkey=anothervalue"; var ajax = new XMLHttpRequest(); ajax.open("POST",url,false); ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); ajax.send(postData); When doing it this way I receive the correct values in $_POST. $HTTP_RAW_POST_DATA is empty. When not defining the request header $HTTP_RAW_POST_DATA contains the data and $_POST is empty.