Re: $_SERVER['QUERY_STRING'] empty when using post?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: $_SERVER['QUERY_STRING'] empty when using post?

From: ChronoFish <deja@chronofish.com>
Date: Mon Nov 21 2005 - 03:43:28 CET

"...So there's no better way to get the string when using post other
than
compiling it yourself?..."

What do you mean "compile it yourself". You get the QUERY_STRING - but
it happens to be blank - that's just the nature of a POST. It's not
inconveivable that your Form's "action" looks like this:
"http://somehost.com/form_handler?sentby=page1&remotesite=true"

Here your $_GET array would be comprised of:
$_GET['sentby']='page1'
$_GET['remotesite']='true'

Your Query String would be "sentby=page1&remotesite=true" and the
$_POST array would hold the contents of the form vars.

It would be pretty easy to "compile" a post's query string:

foreach ($_POST as $a => $v)
     $postQueryString.= ($postQueryString=="" ? "" : "&" ) ."$a=$v";

Not sure why you'd want to do this, but there it is. BTW, the value of
QUERY_STRING is set by your web server - PHP just gives you access to
it.

-CF
Received on Mon Nov 21 11:14:17 2005