954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

sleep() touble

Good morning!

What I am trying to do is: display some text, wait 3 seconds (so the person can read it) and redirect that person to a different web page.

I can get it to either:

1 - Display the text or
2 - Sleep(3) and redirect them to the specific web page.

But I cannot get it to do both.

Can somebody please point me in the right direction?

Thank you in advance

<?php		
echo "Your username and password do not match our records";
sleep(3);
header("Location: movie_registration.php");
?>
JimD C++ Newb
Light Poster
46 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

There are many problems with that.
1 - Unless you spacificaly tell it, PHP will wait till the end of the script before sending ANY information to the browser so that script would not be sent till after 3 seconds.
2 - If it was shown then header() would not work as headers need to be sent before any data.
3 - Most browsers (IE, Netscape/firefox etc) only update the display every 100bites or so

Try this

<?php
header("Refresh: 3;URL=movie_registration.php");		
echo "Your username and password do not match our records";
?>

This will display the page but tell the browser to refresh after 3 seconds to the new page
Regards,
Sam Rudge

samarudge
Posting Whiz
359 posts since May 2008
Reputation Points: 26
Solved Threads: 31
 

Oh that worked perfectly!

Thank you so much for the explanation! That makes sense to me now.

- Jim

JimD C++ Newb
Light Poster
46 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You