header ("Location: ") not redirecting, any suggest


I have searched and searched for an answer to what I am doing wrong. I have used Swishmax to make a form which is here http://www.fortworthmovers.com/form.htm and once the submit button is pressed I have the information sent to 2 different email addresses. This part works fine, but I want it to redirect to a thank you page which is here http://www.fortworthmovers.com/thankyou.htm. But nothing happens when the submit button is pressed (other than the info being emailed). How can I get it to redirect to the thank you page?

I am a newb in PHP, obviously…Here is the PHP file that I am using:


<?php $name = $HTTP_POST_VARS['Name']; $email = $HTTP_POST_VARS['Email']; $phoneday = $HTTP_POST_VARS['Phoneday']; $phonenight = $HTTP_POST_VARS['Phonenight']; $movedate = $HTTP_POST_VARS['Movedate']; $fromaddr = $HTTP_POST_VARS['Fromaddr']; $tomaddr = $HTTP_POST_VARS['Toaddr']; $comments = $HTTP_POST_VARS['Comments']; $referred = $HTTP_POST_VARS['Referred']; $comments = stripslashes($comments); $referred = stripslashes($referred); $sendTo = "email1@email.net"; $sendTo2 = "email2@email.org"; $subject = "Message from Contact Form"; $msg_body = "1. Name: $namen"; $msg_body .= "2. E-Mail: $emailn"; $msg_body .= "3. Phone_day: $phonedayn"; $msg_body .= "4. Phone_night: $phonenightn"; $msg_body .= "5. Move_date: $movedaten"; $msg_body .= "6. From_address: $fromaddrn"; $msg_body .= "7. To_address: $tomaddrn"; $msg_body .= "8. Comments: $commentsn"; $msg_body .= "9. Referred: $referredn"; $info = "From: ".$name." <".$email.">"; mail($sendTo, $subject, $msg_body, $info); mail($sendTo2, $subject, $msg_body, $info); header("Location: http://www.fortworthmovers.com/thankyou.htm"); exit; ?>


Thank you for your help!!!

Admin Edit: Added [php] tags for readability. Please see http://phphelp.com/guidelines.php for posting guidelines.


Uuhm, why are you using flash for your form? I think the problem’s in there, not in the PHP.


I don’t know why the header is not working but you could also use a Meta Refresh to redirect.

See http://webdesign.about.com/od/metatagli … 80300a.htm for information on redirecting through a meta refresh.


When I tried the form, it didn’t do anything at all, so I’m not sure if it reaches the page at all. Besides that, I’m not sure about this, but I think the mail() function actually sends the headers (and headers can’t be resent).


Thanks for the replies.


From what I read about the meta refresh, it looks like you set it to redirect after a certain time period. I need it to redirect after they click the submit button. Some people may take longer than others to fill out the form. The thank you page is confirmation that the information they filled out on the form was sent. Let me know if I’m reading this wrong.


I made the form in Swish (Flash) because there was an easy tutorial and I didn’t know any other way to make the form. I will try and see if there is a tutorial on making the same form in Dreamweaver MX and not use Flash to see if that’s the problem.

I had read somewhere the if an HTML command is already sent to the browser then it will ignore any other commands, such as header (Location:). I don’t know how to re-write this though so I will get my email and still redirect. Any suggestions?



You could substitute the header() line with an echo “something here”; line, and see if that shows up. If it does, you know that the headers are somehow not being sent. (An alternative to this is checking the headers with headers_sent(), but I’ve never used that before).

In Peg110’s example, you could replace the header() line with the following:

[php]echo “”;
echo “”;
echo “”;[/php]


I re-made the form in Dreamweaver and it appears to be working properly now. Thanks!