Swenglish Posted January 13, 2011 Share Posted January 13, 2011 Hi! I am not great at using php but do use it to process forms on websites. I always use the same script and just change the relevant sections for each website. This usually works with no problems. I am writing an mailing list subscribe/unsubscribe form my website and it works fine as in I get the email sent through with all the information on it and the automated reply gets sent out etc. The problem is that once the user hits Submit instead of going to the redirect page it stays on the php page. if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a company name, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.hillsideweb.co.uk/unsubthanks.html" );} Like I say this exact script works on another site of mine perfectly well, can someone please help me solve this. The form is found on http://www.hillsideweb.co.uk/unsubscribe.html I hope this makes sense! Many thanks Swenglish Quote Link to comment https://forums.phpfreaks.com/topic/224299-simple-form-problem/ Share on other sites More sharing options...
taquitosensei Posted January 13, 2011 Share Posted January 13, 2011 Make sure that send is True. If it is then add an exit after the redirect. if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a company name, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) { echo "Send is true."; die(); // if you get this then remove this line and try it again. header( "Location: http://www.hillsideweb.co.uk/unsubthanks.html" ); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/224299-simple-form-problem/#findComment-1158902 Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 Replace from the if( $send line on with: if( $send ) { if( headers_sent() ) { echo 'Headers already sent, can\'t redirect.'; } else { header( "Location: http://www.hillsideweb.co.uk/unsubthanks.html" ); } } Quote Link to comment https://forums.phpfreaks.com/topic/224299-simple-form-problem/#findComment-1158914 Share on other sites More sharing options...
Swenglish Posted January 13, 2011 Author Share Posted January 13, 2011 Thanks for the reply and the help Quote Link to comment https://forums.phpfreaks.com/topic/224299-simple-form-problem/#findComment-1158977 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.