greggustin Posted February 19, 2008 Share Posted February 19, 2008 guess I am having trouble with the "LOCATION" command? ie after I have the user hit submit - it dumps to the 'mail.php page (which is very simple - ie not a full html page) do I have to make the mail.php into a full stylized html? hope not thought I could do a redirect back to the origination page in the website I commented out the location command as it was not working idea? <?php $Name=$_POST['Name']; $email=$_POST['email']; $comments=$_POST['comments']; $to="[email protected]"; $message=" From: $Name\n E-Mail: $email\n comments: $comments"; $headers = "From: $email\r\n"; $headers .= "BCC: [email protected]\r\n"; mail($to,"Comments From $Name", $message, $headers) ; echo "\n\n\n\n\n\n\n . . . . . Thank-you for you Inquiry <br> Some one will contact you shorlty"; //header( "Location: /thankyou.html" ); ?> Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/ Share on other sites More sharing options...
aschk Posted February 19, 2008 Share Posted February 19, 2008 You CAN'T echo before you do a header. So remove your echo statement and it'll redirect as expect. Also an error message would be good but i expect it's saying "header already sent..." Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470515 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 You can't send a location header after you echo content. My suggestion is to get rid of the echo, and put your thank you message on thankyou.html. Then uncomment the header line below, and for good measure but an exit() after the header command. Here is the revised code: <?php $Name=$_POST['Name']; $email=$_POST['email']; $comments=$_POST['comments']; $to="[email protected]"; $message="From: $Name\nE-Mail: $email\nComments: $comments"; $headers = "From: $email\r\n"; $headers .= "BCC: [email protected]\r\n"; mail($to,"Comments From $Name", $message, $headers) or die("Could not send email"); header("Location: /thankyou.html"); exit; ?> Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470516 Share on other sites More sharing options...
greggustin Posted February 19, 2008 Author Share Posted February 19, 2008 wow 2 great replys so fast thanks will try them now Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470519 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 yeah, sorry for the double post aschk...it didn't give me the normal warning that someone had posted while I was writing mine Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470522 Share on other sites More sharing options...
greggustin Posted February 19, 2008 Author Share Posted February 19, 2008 well - it worked - thanks now - trying to be a 'good member' here but cannot find the "Topic Solved" link referenced in the stickies?? Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470531 Share on other sites More sharing options...
rhodesa Posted February 19, 2008 Share Posted February 19, 2008 To my knowledge the Topic Solved button is still broken :-\ Link to comment https://forums.phpfreaks.com/topic/91879-simple-question-after-submit-how-do-i-direct-the-next-page/#findComment-470539 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.