Page 1 of 1

Using a link with variables with the header(location command

Posted: Tue Jul 13, 2004 8:09 am
by supaseeds
ImageBech100 | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Code: Select all

echo "<a href="index.php?REQ=view&id=$id&page=$_GET[page]&cat=$_GET[category]&subcat=0&subsubcat=0">";
The above works. This doesn't:

Code: Select all

header("Location:index.php?REQ=view&id=$id&page=$_GET[page]&cat=$_GET[category]&subcat=0&subsubcat=0");
The links are exactly the same but it won't work for the header command, only for a link. The header command is in a small form so that when they click it, the form can do something else as well as forwarding them to the right page...
Any suggestions on how to get it working?

ImageBech100 | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

P.S

Posted: Tue Jul 13, 2004 8:10 am
by supaseeds
The header command just sends it to index.php ignoring the rest of the link

Posted: Tue Jul 13, 2004 8:34 am
by patrikG
1. Use PHP tags around PHP code
2. The GET-variables as you're passing them are invalid. One solution would be to "quote them out" e.g.

Code: Select all

header("Location:index.php?REQ=view&id=".$id."&page=".$_GET[page]);
etc.