Matthew Zimmerman mz34 at
Tue Mar 11 11:09:01 EST 2003

Ok, this may sound like a really naive question, but I will ask anyway.

What is the predefined variable $QUERY_STRING ? The PHP manual says:

The query string, if any, via which the page was accessed.

That definition is a bit tautological:) I ask because I have some code 
I grabed from a website and it contains the line:

<form action="<?=$PHP_SELF?><?if($QUERY_STRING){ echo"?". 

I am guessing this means if the form has been submitted, the key/value 
pairs will be contained in a variable called $QUERY_STRING, but maybe I 
am way off there?

Just to test I made a simple form:

<form action="test2.php" method="post">

Name<input type="text" name="name">
Address<input type="text" name="address" >
Title<input type="text" name="title" >
<input type="submit" name="Submit"">

I sent that to


$x= $_POST[name];
$y= $_POST[address];
$z= $_POST[title];

print ("$x ");
print ("$y ");
print ("$z ");
print ($QUERY_STRING);

But nothing prints out for $QUERY_STRING. I tired both POST and GET.

Thanks! I am asking this question mostly out of curiosity. The code I 
downloaded works fine. I just want to know why it works.


More information about the talk mailing list