passing a variable to a redirected page

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
james20
Forum Newbie
Posts: 9
Joined: Fri Aug 21, 2009 8:54 am

passing a variable to a redirected page

Post by james20 »

I need to pass a variable from the current page to a redirect of the same page.

For instance, submit.php?step=10 is where I would need to set the variable. Then I redirect back to submit.php and check if that variable is set.


I tried using:

Code: Select all

 
http_redirect("submit.php", array("edited" => 1, true, HTTP_REDIRECT_PERM);
 
with:

Code: Select all

 
isset($_SESSION['edited'])
 
That did not work, but I'm not sure that's the best way of doing things. In short, I simply want to set a variable that I can access from a page that I redirect to.

What are my options for doing this?
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: passing a variable to a redirected page

Post by Mirge »

james20 wrote:I need to pass a variable from the current page to a redirect of the same page.

For instance, submit.php?step=10 is where I would need to set the variable. Then I redirect back to submit.php and check if that variable is set.


I tried using:

Code: Select all

 
http_redirect("submit.php", array("edited" => 1, true, HTTP_REDIRECT_PERM);
 
with:

Code: Select all

 
isset($_SESSION['edited'])
 
That did not work, but I'm not sure that's the best way of doing things. In short, I simply want to set a variable that I can access from a page that I redirect to.

What are my options for doing this?
Instead of using $_SESSION['edited'], try accessing $_GET['edited']. Let me know if that works please.
Post Reply