Passing a variable via the php header redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Passing a variable via the php header redirect

Post by edawson003 »

For some reason, the below is erroring out. Any thought how I can get this to work with variable?
header( "Location: http://www.url.com/file.php?maexid=$_GET['maexid']" );
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Passing a variable via the php header redirect

Post by requinix »

Bad syntax. If you want to put a variable like that in a string you need to do it differently.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Passing a variable via the php header redirect

Post by papa »

Can probably do it like this:

Code: Select all

 
$maexid = $_GET['maexid'];
header( "Location: http://www.url.com/file.php?maexid=$maexid" );
 
 
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: Passing a variable via the php header redirect

Post by edawson003 »

Thanks!
Post Reply