Forum Moderators: coopster

Message Too Old, No Replies

PHP sending data to next page by $_GET

except for 1st, values for other variables not transferred to new page

         

zollerwagner

6:33 am on Aug 15, 2005 (gmt 0)

10+ Year Member



After processing some form input, I want to send the user to a new page like this:

header("location: /page.html?mode=del&cat=$cat&ann=$ann");

When I do that, the new page appears and the new page receives the value for the first variable. For some reason the second and third parts of the data aren't received in the new page, although they are present right before this line in the sending page.

What am I doing wrong?

grandpa

7:47 am on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can check what's arriving at the new page.

foreach ($_GET as $key=>$val) echo "<br>$key $val";

Also, have you tried just using the ampersand? It could be that &amp; isn't being handled as you might expect.
header("location: /page.html?mode=del&cat=$cat&ann=$ann");

mcibor

8:44 am on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think, that you have to use ampersant, not the html symbol of it:

header("Location: /page.html?mode=del&cat=$cat&ann=$ann");

What's in the $cat and $ann? Remember, that they cannot have any & or spaces!

Best regards
Michal Cibor

zollerwagner

4:47 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



Thanks for the responses.

Interestingly, it does work if I use & and not &amp; .

Perhaps I've taken the use of &amp; too far. Given that this isn't a link and doesn't appear in the HTML at all, maybe there is no need to use the &amp;?

gliff

5:50 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



Perhaps I've taken the use of &amp; too far. Given that this isn't a link and doesn't appear in the HTML at all, maybe there is no need to use the &amp;?

You're correct. There's no need for the &amp; here. This never shows up in an HTML document, so it will never face a validator, so raw ampersands are the correct way to go.

However, you should be encoding your url variables. There are certain characters that can't be send through a URL "raw". Look into the the urlencode [us3.php.net] function.

header("location: /page.html?mode=del&cat=".urlencode($cat)."&ann=".urlencode($ann));