NYCPHP Meetup

NYPHP.org

[nycphp-talk] What is $QUERY_STRING ?

Jerry Kapron nyphp at NewAgeWeb.com
Tue Mar 11 16:08:09 EST 2003


replace $_GET['$action']
with $_GET['action']

Jerry

--
42.7% of all statistics are made up on the spot.

-----Original Message-----
From: louie <louie at zibi.co.il>
To: NYPHP Talk <talk at nyphp.org>
Date: Tuesday, March 11, 2003 3:56 PM
Subject: Re: [nycphp-talk] What is $QUERY_STRING ?


>greetings,
>
>first i like to say that this subject dont realy
>have a lot of info so many people i know including myself having problem
>understanding it the first time,
>
>now i want to ask for the best way to deal with calling function
>in a url
>
>function one(){
>
>echo "bla bla";
>
>}
>
>function two(){
>echo "<a href=\\"$_SERVER[PHP_SELF]?action=one\\">one</a>";
>}
>
>switch($_GET['$action']){
>case "one":
>    one();
>    break;
>    default:
>    two();
>     break ;
>}
>
>this would work fine if the register globals on , and even than
>$action you will have undefined var ($action),
>but when register globals off this wont work,
>what is the best way to fix this problem, if you have many pages
>like that and you want to change your php.ini setting of register globals
to
>off
>without messing around with the code too much?
>
>
>
>----- Original Message -----
>From: "David Sklar" <sklar at sklar.com>
>To: "NYPHP Talk" <talk at nyphp.org>
>Sent: Tuesday, March 11, 2003 8:25 AM
>Subject: RE: [nycphp-talk] What is $QUERY_STRING ?
>
>
>> $QUERY_STRING is the stuff after the "?" in a GET URL:
>>
>> http://www.example.com/cart.php?item=cereal&quantity=56
>>
>> $QUERY_STRING (or $_SERVER['QUERY_STRING']) is "item=cereal&quantity=56".
>>
>> It doesn't have to be key/value pairs:
>>
>> http://www.example.com/cart.php?buy
>>
>> $QUERY_STRING is "buy".
>>
>> You didn't see it in the form you used below because the method was POST.
>> Change it to GET and watch the query string bloom.
>>
>> David
>>
>> On Tuesday, March 11, 2003 11:09 AM, Matthew Zimmerman wrote:
>>
>> > 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/ ---
>
>




More information about the talk mailing list