0

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']);
?>

Edited by nick3592: n/a

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Zagga
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 <meta http-equiv="refresh" content="2; url=http://webpage/">

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 <meta http-equiv="refresh" content="2; url=http://webpage/">

ill try thanx for reply.

0

Hi nick3592,

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

echo $_SESSION['message'];

Zagga

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.