ktstowell Posted October 19, 2008 Share Posted October 19, 2008 Hey there! Can anyone tell me why when i add the header redirect on the top of my script my form no longer send the form data via email? <?php header ('Location: http://www.blueleafss.com/contact/thanks.html'); exit (); if (isset($_POST['Sumbit'])) { echo '<h1>Thank you for contacting Blue Leaf Systems and Support!</h1>'; }else{ $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $phone = $_POST['phone']; $slocation = $_POST['slocation']; $clocation = $_POST['clocation']; $comments = $_POST['comments']; $text = ''; foreach ($_POST as $name => $value) { if (is_array($value)) { $text .= sprintf("%s: %s\n", $name, join('', $value)); } else { $text .= sprintf("%s: %s\n", $name, $value); } } $headers = 'From: ' . $_GET['from'] . "\r\n" . mail('myemail@mysite.com', 'Form data', $text); } ?> any and all help would be uber appreciated! thank you! Quote Link to comment Share on other sites More sharing options...
corbin Posted October 19, 2008 Share Posted October 19, 2008 Errr, you've obviously misunderstood how exit works. http://php.net/exit Quote Link to comment Share on other sites More sharing options...
ktstowell Posted October 19, 2008 Author Share Posted October 19, 2008 just to clarify (after reading some other topics on headers) i receive no errors when i run this script, it simply does not send any info to my email unless the header is removed. Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 19, 2008 Share Posted October 19, 2008 As someone already stated, it's because you kill (exit) the script before it gets there... This has nothing to do with the header() call but rather exit; much like the following will never print "Hello World" <?php exit; echo "Hello World"; // I will never be printed Quote Link to comment Share on other sites More sharing options...
ktstowell Posted October 19, 2008 Author Share Posted October 19, 2008 lmao, word...but is it necessary for the redirect? meh, in the mean time ill experiment, thanks for the reply. Quote Link to comment 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.