Page 1 of 1

Pause and re-load

Posted: Tue Apr 13, 2010 5:14 pm
by agibsonsw
Hello.
I want to display a message "You haven't selected a file" pause and then re-direct the user.
I'm using sleep(2) but can't then use a header() because content has already been sent to the browser.

I assume output-buffering is the way to go, but am struggling to get it to work? Thanks, Andy.

Re: Pause and re-load

Posted: Tue Apr 13, 2010 5:56 pm
by s.dot
Use the meta refresh tag

Code: Select all

<meta http-equiv="refresh" content="2;url=http://example.com">

Re: Pause and re-load

Posted: Tue Apr 13, 2010 6:12 pm
by agibsonsw
Thanks for your response.
Shouldn't a meta tag occur within the head tag? I'm trying to re-direct the user after an error message within the page.
I'll try it anyway.
(I've found a Javascript solution, but I was hoping to get a PHP header() and output-buffering combination to work.) Ta, Andy.

Re: Pause and re-load

Posted: Tue Apr 13, 2010 6:21 pm
by s.dot
Yes, but you can generate the head tag before the message is displayed. A page is requested at once and the result would be sent to the browser at the same time.

So, what would happen is, the user would see the message, wait two seconds, then be redirected.

Meta refresh is ideal for this situation. Javascript won't always work, and output buffering with the redirect would be overkill.