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");
?>

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

commented: Perfect solution to my problem. Thank you! +1

Oh that worked perfectly!

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

- Jim

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.