note 79681 deleted from reserved.variables by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: email at martinclewett dot com 

----

$_POST[...] does not support dots or spaces in the HTML form element names; replacing them with underscores.  Strictly speaking spaces break W3 but not dots. Therefore I have written this workaround.  It uses the $GLOBALS['HTTP_RAW_POST_DATA'] variable and converts it using urldecode(...).  The function outputs an associative array that unlike $_POST can handle dots and spaces.  You will need to set always_populate_raw_post_data to on in your php.ini file.
  
<?php
function get_posted_data_from_raw(){
   //For this to work the always_populate_raw_post_data configuration directive in php.ini need to be on
   if(isset($GLOBALS['HTTP_RAW_POST_DATA'])){
       $temparr1 = split('&',$GLOBALS['HTTP_RAW_POST_DATA']);
       foreach($temparr1 as $tempstr1){
           $temparr2 = split('=',$tempstr1);
           $post[urldecode($temparr2[0])] = urldecode($temparr2[1]);
       }
       return $post;
   }
}
?>

Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.