Passing a variable thru 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 thru header redirect

Post by edawson003 »

How can I get a $variable to pass thru a url set by php redirect code ($recordid for example)?

Code: Select all

 
$recordid = $_GET['fid'];
 
header( "Location: http://www.someurl.com/membersarea/edit.php" );
I want the url to actual work :
http://www.someurl.com/membersarea/edit.php?fid=117
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Passing a variable thru header redirect

Post by Eric! »

I usually just redirect directly with the query data in the string.

Code: Select all

header('Location: http://www.someurl.com/membersarea/edit.php?fid='.$recordid);
User avatar
edawson003
Forum Contributor
Posts: 133
Joined: Thu Aug 20, 2009 6:34 am
Location: Los Angeles, CA - USA

Re: Passing a variable thru header redirect

Post by edawson003 »

That works. Thx! :D
Post Reply