By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

Beginner Needs Help With HTTP Parameters

P: n/a
I am trying an example from an O'Reilly book that I just can't get to work.
Can someone tell me where I am going wrong. According to the book, I should
see the values of the HTTP request echoed by the PHP. But obviously they're
not there. All I see is "regionName is wineType is"

Any help would be appreciated.

// index.html
<HTML>
<HEAD>
<TITLE>Explore Wines</TITLE>
</HEAD>

<BODY BGCOLOR="#ffffff">

Explore all our <A
HREF="example.5-4.php?regionName=All&amp;wineType=All">wines</A>

<BR>
Explore our <A HREF="example.5-4.php?regionName=All&amp;wineType=Red">red
wines</A>

<BR>
Explore our <A
HREF="example.5-4.php?regionName=Riverland&amp;wineType=Red">premi um
reds from the Riverland</A>

<BR>
</BODY>
</HTML>
// example.5-4.php
<HTML>
<HEAD>
<TITLE>Parameters</TITLE>
</HEAD>
<BODY>
<?php
echo "regionName is $regionName\n";
echo "wineType is $wineType\n";
?>
</BODY>
</HTML>
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In order to get those variables from the URL, change the $regionName
variable to $_GET['regionName'] and the $wineType to $_GET['wineType'].

PHP expects those variables to be set somewhere else in the PHP file,
so it doesn't know to look in the URL for the variable.

Jul 17 '05 #2

P: n/a
> I am trying an example from an O'Reilly book that I just can't get to
work.
Can someone tell me where I am going wrong. According to the book, I should see the values of the HTTP request echoed by the PHP. But obviously they're not there. All I see is "regionName is wineType is"


In the early days, PHP made these variables available to use, from version 4
and up however (I believe) they are typically stored in the global arrays
$_GET or $_POST. To minimize the changes required for the O'Reilly examples
to work, just type the following command at the top of your .php file:

<? import_request_variables("gP", "") ?>

Also check out:

http://php.net/manual/en/function.im...-variables.php
Jul 17 '05 #3

P: n/a
> In order to get those variables from the URL, change the $regionName
variable to $_GET['regionName'] and the $wineType to $_GET['wineType'].

PHP expects those variables to be set somewhere else in the PHP file,
so it doesn't know to look in the URL for the variable.

Thanks to both! I guess my book is a bit dated, although it is March 2002.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.