954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

redirect problem

hi i have done a header redirect to stop from the resending data in most browser but seem to have a problem with showing messages after that's done. After the user finishes doing something he or she gets redirected and there[s a message in a session either error or success. When the user gets redirected once the message is suppose to show and than after it shows it unsets but the problem im facing is that it apparently unsets before showing the message. Heres some of the code

<?php
$_SESSION['message'] = "Your post has been successful";
header("Location: login.php");

echo $message;
unset ($_SESSION['message']);
?>
nick3592
Light Poster
35 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

Use session_start(); before assigning the value to $_SESSION;

Also not that IE doesn't play nice with setting session before header redirects. Instead use

aquilax
Junior Poster in Training
73 posts since Jul 2010
Reputation Points: 18
Solved Threads: 11
 

Use session_start(); before assigning the value to $_SESSION;

Also not that IE doesn't play nice with setting session before header redirects. Instead use

ill try thanx for reply.

nick3592
Light Poster
35 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

Hi nick3592,

I don't see where $message is being set.
Try changing the echo statement to . . .

echo $_SESSION['message'];

Zagga

Zagga
Posting Whiz in Training
257 posts since Dec 2009
Reputation Points: 22
Solved Threads: 54
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: