473,382 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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
</SELECT>
</td> <td>
<INPUT TYPE=submit VALUE="Search">
</td>
</form>
</div>
<?php exit; }
echo ("the catagory variable was set");
Jul 17 '05 #1
7 10684
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:
search.php?search=&catagory=Search+All+Catagories

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>
</td>
</form>
</div>


You forgot to close the table row and the table.

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

Regards,
Matthias
Jul 17 '05 #4
Matthew Robinson wrote:
search.php?search=&catagory=Search+All+Catagories

if (empty($catagory)) {


Read this, _all_ of this

http://www.php.net/manual/en/languag...s.external.php
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:
search.php?search=&catagory=Search+All+Catagories

if statement:

if (empty($catagory)) {


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

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

Regards,
Matthias
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
4
by: Doruk | last post by:
The problem that we are experiencing is simple: We want to pass certain parameters from a page with several server controls to another page. We want to do this in a dotnet compliant manner,...
1
by: Eric | last post by:
Hello, I am trying to come up with the best way to pass large amounts of data from page to page, namely a data table. The user needs to enter data into a form in one page and confirm it on...
2
by: Roy | last post by:
Hey all, Is it possible to pass session variables between pages in separate projects? For example: inetpub\thisproject\blah.aspx has a session variable and response.redirects the user to...
7
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
28
by: Skeets | last post by:
i'm passing session and hidden variables between pages. not to mention post values. i'm a little concerned that someone with sufficient knowledge could spoof these vlaues and manipulate the...
1
by: Carly | last post by:
Hi, I work in Visual Basic .NET 2002 using ASP.NET. I am wondering what would be the best way to store/pass variables between pages. (Sessions are sooo simple to use but I hear they are not the...
7
by: Smokey Grindle | last post by:
For a website that has users logged into it using sessions, its it best to pass data between pages in session variables or through query strings?
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
6
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.