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

Recommended Answers

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/">

Jump to Post

All 3 Replies

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/">

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.

Member Avatar

Hi nick3592,

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

echo $_SESSION['message'];

Zagga

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.