Pause and re-load

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agibsonsw
Forum Newbie
Posts: 8
Joined: Sun Apr 11, 2010 1:58 pm

Pause and re-load

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Pause and re-load

Post by s.dot »

Use the meta refresh tag

Code: Select all

<meta http-equiv="refresh" content="2;url=http://example.com">
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
agibsonsw
Forum Newbie
Posts: 8
Joined: Sun Apr 11, 2010 1:58 pm

Re: Pause and re-load

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Pause and re-load

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply