471,896 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,896 software developers and data experts.

passing variables between pages

i read a tutorial the other day on passing variables between php pages
using a html form and setting the action to the php page to parse, can
anybody see anything wrong with the code below? the problem is, that the
page always loads the html form, and i cant work out why this is so, even
after i select a catagory from the drop down list and press search. any1
have any idea's? TIA.

the code:

if (empty($catagory)) { ?>
<div align=center>
<form action="<?php $PHP_SELF ?>" method="GET"> <table>
<tr> <td>
<INPUT name=search>
</td> <td>
<SELECT NAME=catagory SIZE=1>
<OPTION any>Search All Catagories
<OPTION floral>Floral Creations
<OPTION lighting>Decorative Lighting
<OPTION kitchenware>Kitchenware & Crockery <OPTION
furniture>Fancy Goods & Furniture
</td> <td>
<INPUT TYPE=submit VALUE="Search">
<?php exit; }
echo ("the catagory variable was set");
Jul 17 '05 #1
7 10595
just thought i would add, that i cant remember the url of the tutorial,
and the notes i took didn't include that part for some unknown reason
Jul 17 '05 #2
just thought of checking the url - thats right, so the problem must be in
my if statement:

end of url:

if statement:

if (empty($catagory)) {

Jul 17 '05 #3
Matthew Robinson <ma*************@hotmail.com> schrieb:
<form action="<?php $PHP_SELF ?>" method="GET"> <table>
Set your error_reporting to E_ALL, so that PHP will inform you of any
errors. Then have a look at the resulting source code of the HTML page
and you should find your error pretty fast. You use $PHP_SELF as a
function, but what you really want is the value of this variable.
Additionally I'd suggest that you use $_SERVER['PHP_SELF']. $_PHP_SELF
will not exist if register_globals is off (which is default since PHP
4.2.0). So your code should be:

<form action="<?php echo($SERVER['PHP_SELF'] ?>" method="GET"> <table>

You forgot to close the table row and the table.

00:53AM in Germany. I'm going to bed now. :-)

Jul 17 '05 #4
Matthew Robinson wrote:

if (empty($catagory)) {

Read this, _all_ of this

and follow a few of the links there, too

a (the usual?) way to do what you want is

if (empty($_GET['catagory'])) {
but do not bypass reading the manual :)
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
thanks again pedro - i am gonna read the manual now (the link you gave me)
Jul 17 '05 #6
Matthew Robinson <ma*************@hotmail.com> schrieb:

if statement:

if (empty($catagory)) {

if (isset($_GET['catagory'])) {

And you might want to change "catagory" to "category". :-)

Jul 17 '05 #7
On Thu, 08 Jan 2004 23:34:32 +0000, Matthew Robinson wrote:
i read a tutorial the other day on passing variables between php pages

A lot of on-the-web php tutorials (webmonkey, for example) have gotten out
of date.

Look up register_globals()!

| Jeffrey Silverman |
| jeffrey-AT-jhu-DOT-edu|

Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Consuelo Guenther | last post: by
1 post views Thread by Eric | last post: by
2 posts views Thread by Roy | last post: by
7 posts views Thread by Khai | last post: by
28 posts views Thread by Skeets | last post: by
1 post views Thread by Carly | last post: by
7 posts views Thread by Smokey Grindle | last post: by
22 posts views Thread by K. A. | last post: by
6 posts views Thread by coool | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.