NYCPHP Meetup

[nycphp-talk] What is $QUERY_STRING ?

CHUN-YIU LAM chun_lam at hotmail.com
Wed Mar 12 15:28:02 EST 2003


Why do you need QUERY_STRING?  PHP does separate the name-value pair to 
$_GET array.






----Original Message Follows----
From: Matthew Zimmerman <mz34 at nyu.edu>
Reply-To: talk at nyphp.org
To: NYPHP Talk <talk at nyphp.org>
Subject: [nycphp-talk] What is $QUERY_STRING ?
Date: Tue, 11 Mar 2003 11:09:05 -0500
Received: from parsec.nyphp.org ([66.250.131.26]) by mc7-f2.law1.hotmail.com 
with Microsoft SMTPSVC(5.0.2195.5600); Tue, 11 Mar 2003 08:09:33 -0800
Received: from nyphp.org (parsec.nyphp.org [66.250.131.26])by 
parsec.nyphp.org (8.12.6/8.12.6) with ESMTP id h2BG95JH064800for 
<chun_lam at hotmail.com>; Tue, 11 Mar 2003 11:09:30 -0500 (EST)(envelope-from 
null at nyphp.org)
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Message-Id: <200303111609.h2BG95JH064800 at parsec.nyphp.org>
X-Paralist-Archived: <http://nyphp.org/list/paralist_archive.php?L_mid=3395>
X-List-Software: Paralist 0.6
List-ID: <nyphptalk.nyphp.org>
List-Owner: <mailto:listmaster at nyphp.org>
List-Archive: <http://nyphp.org/list/paralist_archive.php?L_lid=2>
List-Subscribe: <http://nyphp.org/list/>
List-Unsubscribe: <http://nyphp.org/list/>
Organization: New York PHP
X-Mailer: Paramail 0.5
Return-Path: null at nyphp.org
X-OriginalArrivalTime: 11 Mar 2003 16:09:34.0967 (UTC) 
FILETIME=[9BA78070:01C2E7E8]

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:

'QUERY_STRING'
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"?".
$QUERY_STRING;}?>"method="POST">

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"">
</form>

I sent that to

<?php

$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.

Matt



--- Unsubscribe at http://nyphp.org/list/ ---




_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus




More information about the talk mailing list