Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem using header("Location: url") when also using Sleep(10)... 1

Status
Not open for further replies.

snayjay

Programmer
Oct 23, 2001
116
US
I am using Flash on my website so the form is on a flash page... this is not my problem, that works just fine. I call getURL("Team4Reg.php","","POST"); in my Flash page and it calls the right .php file. Which then processes my form just fine, sending the appropriately formatted emails to the right place, but then at the end of the php file I ask it to echo some text, wait 10 seconds and redirect

Code:
mail($sendTo, $subject, $msg_body, $header_info);
echo("Your Registration Request has been sent, please wait for an email confirming your spot in our tournament.<BR>
You will be returned to our website in 10 seconds.<BR>
Thank you for registering.");
sleep(10);
header("Location: /BCS/Index.html");
?>

All that is happening is the email processing and the echo. The redirect doesn't work. But if I take out the echo, then the redirect works. I think it's a timing issue. Because when I run the echo it takes a few seconds for the echo to appear... but if I //comment out the echo it runs the redirect almost instantly. Is this timing out and missing my redirect?!? How do I fix it. Thanks in advance.

Snayjay
 
header(location...) doesn't work after outputting anything to the browser. You should be getting a "headers already sent" error.

In any case you'll have to either not use the header method or not output anything to the screen.








----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for letting me know....star for your efforts! I can handle it thru Flash...no biggie, was just trying out things with PHP for the first time and didn't realize it. Thanks again!
 
Yes, But that defeats the purpose, as you wont see the message anyway because by the time you get to the header, the cache hasn't been flushed yet, so nothing appears.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Indeed you are correct I focussed on the header not the message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top