rootKID Posted June 10, 2012 Share Posted June 10, 2012 Hello... the title says it all... how to make a header() location, just after some coble of seconds?... 2 Link to comment Share on other sites More sharing options...
boen_robot Posted June 10, 2012 Share Posted June 10, 2012 Use the Refresh header. It starts with a timeout, and can optionally take a different URL to redirect to, e.g. header('Refresh: 2; url=http://google.com'); will redirect to google.com after 2 seconds. Link to comment Share on other sites More sharing options...
rootKID Posted June 10, 2012 Author Share Posted June 10, 2012 ahh, gracias! ... Link to comment Share on other sites More sharing options...
niche Posted June 10, 2012 Share Posted June 10, 2012 I'm interested in why you want to do this? Link to comment Share on other sites More sharing options...
Guest So Called Posted June 10, 2012 Share Posted June 10, 2012 How about an old page that has been moved to a new address? The old page says "you are being redirected to the new page, please change your bookmarks" and then 2 seconds later you're automatically on the new page. 1 Link to comment Share on other sites More sharing options...
dsonesuk Posted June 10, 2012 Share Posted June 10, 2012 In that case it would be better to do a 301 permanent redirect. Link to comment Share on other sites More sharing options...
Guest So Called Posted June 10, 2012 Share Posted June 10, 2012 Well, yeah, but the OP didn't provide sufficient information to determine that. Link to comment Share on other sites More sharing options...
niche Posted June 10, 2012 Share Posted June 10, 2012 Thanks again dsonesuk and So Called, I never thought of that that way before. Link to comment Share on other sites More sharing options...
getty Posted June 11, 2012 Share Posted June 11, 2012 (edited) You can do the same in PHP with: <?phpecho "You're being redirected to... page";sleep(1000);header("Location: page.php");?> Edited June 11, 2012 by getty Link to comment Share on other sites More sharing options...
rootKID Posted June 11, 2012 Author Share Posted June 11, 2012 one question getty... what does sleep?.... and sorry for late reply, have been in the schools all day... and im so tired right now ...anyways... niche, why... simple... i suppose you have allready seemed my shop website trouble... anyways... i need this in my order_adding.php file, so that the product/order is going to be added, but in the background, while redirecting to an another location after done, and meanwhile on the page, showing the word ''Product Added''... orr somfthing like that... still working on it ... Link to comment Share on other sites More sharing options...
boen_robot Posted June 11, 2012 Share Posted June 11, 2012 one question getty... what does sleep?....See sleep() in the PHP manualYou can do the same in PHP with: <?phpecho "You're being redirected to... page";sleep(1000);header("Location: page.php");?> Have you actually tried this? I'm pretty sure it isn't going to work.[[Testing...]]Yep. Doesn't work. Error 500 due to exceeded timeout. Reducing the timeout to something more reasonable, like 1 second doesn't work either. Depending on how you have your output buffering settings, one of two things happens:1. Redirect after the sleep, without the message ever being visible. This happens when output buffering is on, and since headers are sent before any content, the browser decides to ignore the content and redirect, just as it does normally with redirects.2. The message is visible, and no redirect occurs. This happens when output buffering is off, and since after the echo, the headers are already sent, there's no way for PHP to ask the browser for a redirect. 1 Link to comment Share on other sites More sharing options...
rootKID Posted June 11, 2012 Author Share Posted June 11, 2012 does it ''NEEDS'' to be between the 2 echoes?... the sleep?, i mean... before it will work?. Link to comment Share on other sites More sharing options...
boen_robot Posted June 11, 2012 Share Posted June 11, 2012 No. The two echoes are there only for illustration purposes. How else do you distinguish a delay caused by sleep() vs. a delay caused by a slow script? Link to comment Share on other sites More sharing options...
rootKID Posted June 13, 2012 Author Share Posted June 13, 2012 hmm... did not think of it that way ^^'... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now