Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/56044-page-redirecting/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.