immanuelx2 Posted June 18, 2007 Share Posted June 18, 2007 Hey guys, I have a login.php page that checks the database vs the post data of the login form, and logs the user in. If successful, I want the page to redirect to the previous page ($redirect I have set to $_SERVER['REQUEST_URI'] from the previous page..) anyway... How can i have my page redirect after 5 seconds? The following code does not work: //header... setcookie("id", $userinfo['id'] , time()+60*60*24*31*3 , "/"); $delay = 5; sleep($delay); echo "Redirecting in <b>".$delay."</b> seconds"; header("Location: " . $_POST['redirect']); Warning: Cannot modify header information - headers already sent by (output started at header.php:7) in login.php on line 17 Redirecting in 5 seconds Warning: Cannot modify header information - headers already sent by (output started at header.php:7) in login.php on line 21 Is there a way I can achieve this redirect after the </head> tag is closed? Quote Link to comment https://forums.phpfreaks.com/topic/56044-page-redirecting/ Share on other sites More sharing options...
GingerRobot Posted June 18, 2007 Share Posted June 18, 2007 If you want a time delayed redirect, you'll need to echo out some javascript. PHP cant modify the headers(such as redirecting the page) once you've output something to the screen. Quote Link to comment https://forums.phpfreaks.com/topic/56044-page-redirecting/#findComment-276769 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.