ID: 31417 Comment by: daniel dot kirsch at birgin dot de Reported By: j-spam at starline dot ee Status: No Feedback Bug Type: CGI related Operating System: Linux PHP Version: 5.0.3 New Comment:
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. Previous Comments: ------------------------------------------------------------------------ [2008-05-22 20:46:34] mgb at matthewbelden dot com sorry in the previous comment the pattern should be \r\n not just \n ------------------------------------------------------------------------ [2008-05-22 18:57:33] mgb at matthewbelden dot com This workaround did it for me, the above did not. $pattern = "/\n/"; $replace = "&"; $GLOBALS['HTTP_RAW_POST_DATA'] = preg_replace($pattern, $replace, $GLOBALS['HTTP_RAW_POST_DATA']); if (isset($GLOBALS['HTTP_RAW_POST_DATA']) && !count($_POST)) parse_str($GLOBALS['HTTP_RAW_POST_DATA'] , $_POST); ------------------------------------------------------------------------ [2006-05-16 15:23:38] fabiovh at nospammers dot gmail dot com //workaround if (isset($GLOBALS['HTTP_RAW_POST_DATA']) && !count($_POST)) parse_str($GLOBALS['HTTP_RAW_POST_DATA'] , $_POST); ------------------------------------------------------------------------ [2006-05-15 14:53:58] baker195 at btinternet dot com I'm writing an AJAX application and after using the XLMHttpRequest object to post the data to my server side PHP script, I have to extract the data from $HTTP_RAW_POST_DATA as $_POST is empty. ------------------------------------------------------------------------ [2005-07-18 07:03:55] robbhammack at gmail dot com I'm also having this issue. $_GET and $HTTP_RAW_POST_DATA are populated, but $_REQUEST and $_POST are not. I'm trying to develop an application for php5 but whithout being able to post form data, I'm going to have to go back to php4 which would be a real shame. OS is win2K xp2 PHP Version 5.1.0b3 System Windows NT MINERVA 5.1 build 2600 Build Date Jul 14 2005 20:32:24 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" Server API Apache 2.0 Handler Virtual Directory Support enabled Configuration File (php.ini) Path C:/Development/programs/php5/php.ini PHP API 20041225 PHP Extension 20050617 Zend Extension 220050617 Apache Version Apache/2.0.53 (Win32) PHP/5.1.0b3 DAV/2 Apache API Version 20020903 Loaded Modules core mod_win32 mpm_winnt http_core mod_so mod_access mod_actions mod_alias mod_asis mod_auth mod_autoindex mod_cgi mod_dav mod_dav_fs mod_dir mod_env mod_imap mod_include mod_info mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_userdir mod_php5 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/31417 -- Edit this bug report at http://bugs.php.net/?id=31417&edit=1