champton Posted July 2, 2009 Share Posted July 2, 2009 I have a form that I created in PHP and I take that data and save it to MySQL and then send the email. Everything works great. Data gets saved and email goes out. Where it gets odd, is the end user has to select 1-15 dates and times. They are not required to choose all, but at least 1. If the user selects dates that are not in sequence, the email loops with each date and then prints to the screen rather then being redirected to the thank you page. I will not include the entire code here but only the sendMail funciton so you can see how I am establishing the date and times in the email. I want to know if anyone has come across this before and/or if someone has any input on the issue. I hope this is easy to understand. Just so you know, I call the sendmail funtion after the data gets entered into the database and then after the sendmail function, I do a redirect. Thanks in advance for any input. //function to send email to field office with data function sendEmail() { if(isset($_POST['dnnName'])) { $dnnName = $_POST['dnnName']; } if(isset($_POST['pc'])) { $pc = $_POST['pc']; } //get the region email address switch ($pc) { case "Boone": $pcEmail = "[email protected]"; break; case "Charlotte": $pcEmail = "[email protected]"; break; case "Atlanta": $pcEmail = "[email protected]"; break; case "Denver": $pcEmail = "[email protected]"; break; case "Minneapolis": $pcEmail = "[email protected]"; break; case "Orange County": $pcEmail = "[email protected]"; break; default: echo "[email protected]"; } if(isset($_POST["firstName"])) { $firstName = $_POST["firstName"]; } if(isset($_POST["lastName"])) { $lastName = $_POST["lastName"]; } if(isset($_POST["address"])) { $address = $_POST["address"]; } if(isset($_POST["city"])) { $city = $_POST["city"]; } if(isset($_POST["state"])) { $state = $_POST["state"]; } if(isset($_POST["zip"])) { $zip = $_POST["zip"]; } if(isset($_POST["phone"])) { $phone = $_POST["phone"]; } if(isset($_POST["altPhone"])) { $altPhone = $_POST["altPhone"]; } if(isset($_POST["email"])) { $email = $_POST["email"]; } if(isset($_POST["groupType"])) { $groupType = $_POST["groupType"]; } if(isset($_POST["quantity"])) { $quantity = $_POST["quantity"]; } if(isset($_POST["specialRequest"])) { $specialRequest = $_POST["specialRequest"]; } if(isset($_POST["submitDate"])) { $submitDate = $_POST["submitDate"]; } if(isset($_POST["day1"])) { $day1 = $_POST["day1"]; } if(isset($_POST["day2"])) { $day2 = $_POST["day2"]; } if(isset($_POST["day3"])) { $day3 = $_POST["day3"]; } if(isset($_POST["day4"])) { $day4 = $_POST["day4"]; } if(isset($_POST["day5"])) { $day5 = $_POST["day5"]; } if(isset($_POST["day6"])) { $day6 = $_POST["day6"]; } if(isset($_POST["day7"])) { $day7 = $_POST["day7"]; } if(isset($_POST["day8"])) { $day8 = $_POST["day8"]; } if(isset($_POST["day9"])) { $day9 = $_POST["day9"]; } if(isset($_POST["day10"])) { $day10 = $_POST["day10"]; } if(isset($_POST["day11"])) { $day11 = $_POST["day11"]; } if(isset($_POST["day12"])) { $day12 = $_POST["day12"]; } if(isset($_POST["day13"])) { $day13 = $_POST["day13"]; } if(isset($_POST["day14"])) { $day14 = $_POST["day14"]; } if(isset($_POST["day15"])) { $day15 = $_POST["day15"]; } //create day times from form if(isset($_POST["day1TimeStart"]) and isset($_POST["day1TimeEnd"])) { $day1Time = $_POST["day1TimeStart"] ."-". $_POST["day1TimeEnd"]; } if(isset($_POST["day2TimeStart"]) and isset($_POST["day2TimeEnd"])) { $day2Time = $_POST["day2TimeStart"] ."-". $_POST["day2TimeEnd"]; } if(isset($_POST["day3TimeStart"]) and isset($_POST["day3TimeEnd"])) { $day3Time = $_POST["day3TimeStart"] ."-". $_POST["day3TimeEnd"]; } if(isset($_POST["day4TimeStart"]) and isset($_POST["day4TimeEnd"])) { $day4Time = $_POST["day4TimeStart"] ."-". $_POST["day4TimeEnd"]; } if(isset($_POST["day5TimeStart"]) and isset($_POST["day5TimeEnd"])) { $day5Time = $_POST["day5TimeStart"] ."-". $_POST["day5TimeEnd"]; } if(isset($_POST["day6TimeStart"]) and isset($_POST["day6TimeEnd"])) { $day6Time = $_POST["day6TimeStart"] ."-". $_POST["day6TimeEnd"]; } if(isset($_POST["day7TimeStart"]) and isset($_POST["day7TimeEnd"])) { $day7Time = $_POST["day7TimeStart"] ."-". $_POST["day7TimeEnd"]; } if(isset($_POST["day8TimeStart"]) and isset($_POST["day8TimeEnd"])) { $day8Time = $_POST["day8TimeStart"] ."-". $_POST["day8TimeEnd"]; } if(isset($_POST["day9TimeStart"]) and isset($_POST["day9TimeEnd"])) { $day9Time = $_POST["day9TimeStart"] ."-". $_POST["day9TimeEnd"]; } if(isset($_POST["day10TimeStart"]) and isset($_POST["day10TimeEnd"])) { $day10Time = $_POST["day10TimeStart"] ."-". $_POST["day10TimeEnd"]; } if(isset($_POST["day11TimeStart"]) and isset($_POST["day11TimeEnd"])) { $day11Time = $_POST["day11TimeStart"] ."-". $_POST["day11TimeEnd"]; } if(isset($_POST["day12TimeStart"]) and isset($_POST["day12TimeEnd"])) { $day12Time = $_POST["day12TimeStart"] ."-". $_POST["day12TimeEnd"]; } if(isset($_POST["day13TimeStart"]) and isset($_POST["day13TimeEnd"])) { $day13Time = $_POST["day13TimeStart"] ."-". $_POST["day13TimeEnd"]; } if(isset($_POST["day14TimeStart"]) and isset($_POST["day14TimeEnd"])) { $day14Time = $_POST["day14TimeStart"] ."-". $_POST["day14TimeEnd"]; } if(isset($_POST["day15TimeStart"]) and isset($_POST["day15TimeEnd"])) { $day15Time = $_POST["day15TimeStart"] ."-". $_POST["day15TimeEnd"]; } //end time format if ($state == "NC" || $state == "SC") { $foEmail = "[email protected]"; } if ($state == "FL") { $foEmail = "[email protected]"; } if ($state == "OH" || $state == "IN" || $state == "MI" || $state == "WV") { $foEmail = "[email protected]"; } if ($state == "KS" || $state == "IL" || $state == "MO" || $state == "NE" || $state == "OK") { $foEmail = "[email protected]"; } if ($state == "MD" || $state == "DE" || $state == "NJ" || $state == "PA" || $state == "VA" || $state == "DC") { $foEmail = "[email protected]"; } if ($state == "TN" || $state == "AR" || $state == "KY") { $foEmail = "[email protected]"; } if ($state == "NY" || $state == "CT" || $state == "ME" || $state == "MA" || $state == "NH" || $state == "RI" || $state == "VT") { $foEmail = "[email protected]"; } if ($state == "WA" || $state == "ID" || $state == "MT" || $state == "OR" || $state == "AK") { $foEmail = "[email protected]"; } if ($state == "GA" || $state == "AL" || $state == "MS") { $foEmail = "[email protected]"; } if ($state == "CO" || $state == "AZ" || $state == "NM" || $state == "UT" || $state == "WY") { $foEmail = "[email protected]"; } if ($state == "TX" || $state == "LA") { $foEmail = "[email protected]"; } if ($state == "MN" || $state == "IA" || $state == "ND" || $state == "SD" || $state == "WI") { $foEmail = "[email protected]"; } if ($state == "CA" || $state == "HI" || $state == "NV") { $foEmail = "[email protected]"; } //Create an empty message variable. $message = "". "<h2>Extranet Account: <font color=red>$dnnName</font></h2>" . "<h3>Name: <font color=red>$firstName $lastName</font>" . "</h3>" . "<b>Processing Center</b>: $pc" . "<br>" . "<b>Address</b>: $address" . "<br>" . "<b>City</b>: $city" . "<br>" . "<b>State</b>: $state" . "<br>" . "<b>Zip Code</b>: $zip" . "<br>" . "<b>Phone</b>: $phone" . "<br>" . "<b>Alternate Phone</b>: $altPhone" . "<br>" . "<b>Email</b>: $email" . "<br>" . "**********************************************************" . "<br>" . "<b>Group Type</b>: $groupType" . "<br>" . "<b>Number of People in Group</b>: $quantity" . "<br>" . "<b>Special Requests</b>: $specialRequest" . "<br>" . "**********************************************************" . "<br>"; $message = $message."<b>Date(s) Requesting</b>:". "<br>"; if ($day1 == 'Y') {echo $message = $message . "November 24: $day1Time". "<br>";} if ($day2 == 'Y') {echo $message = $message . "November 25: $day2Time" . "<br>";} if ($day3 == 'Y') {echo $message = $message ."November 27: $day3Time" . "<br>";} if ($day4 == 'Y') {echo $message = $message . "November 28: $day4Time" . "<br>" ;} if ($day5 == 'Y') {echo $message = $message . "November 30: $day5Time" . "<br>";} if ($day6 == 'Y') {echo $message = $message . "December 1: $day6Time" . "<br>" ;} if ($day7 == 'Y') {echo $message = $message . "December 2: $day7Time" . "<br>";} if ($day8 == 'Y') {echo $message = $message . "December 3: $day8Time" . "<br>";} if ($day9 == 'Y') {echo $message = $message . "December 4: $day9Time" . "<br>";} if ($day10 == 'Y') {echo $message = $message . "December 5: $day10Time" . "<br>";} if ($day11 == 'Y') {echo $message = $message . "December 8: $day11Time" . "<br>";} if ($day12 == 'Y') {echo $message = $message . "December 9: $day12Time" . "<br>";} if ($day13 == 'Y') {echo $message = $message . "December 10: $day13Time" . "<br>";} if ($day14 == 'Y') {echo $message = $message . "December 11: $day14Time" . "<br>";} if ($day15 == 'Y') {echo $message = $message . "December 12: $day15Time" . "<br>";} echo $message = $message . "<br>"."<div>Please do not reply to this email. If you have any questions, please contact Volunteer Relations.</div>"; //The mail that we want to use to recevie the submitted information. $to= $pcEmail; //The E-Mail subject $subject = "Subject goes here"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type:text/html;charset=iso-8859-1' . "\r\n"; $headers .= "BCC:" .$foEmail."\n"; $headers .= "From: [email protected]". "\r\n"; //Send message by e-mail. mail($to, $subject, $message, $headers); } Link to comment https://forums.phpfreaks.com/topic/164530-php-mail-problem/ Share on other sites More sharing options...
kenrbnsn Posted July 2, 2009 Share Posted July 2, 2009 Please surround your code with tags when posting code to this forum. Ken Link to comment https://forums.phpfreaks.com/topic/164530-php-mail-problem/#findComment-867822 Share on other sites More sharing options...
champton Posted July 2, 2009 Author Share Posted July 2, 2009 Sorry about that. I forgot. //function to send email to field office with data function sendEmail() { if(isset($_POST['dnnName'])) { $dnnName = $_POST['dnnName']; } if(isset($_POST['pc'])) { $pc = $_POST['pc']; } //get the region email address switch ($pc) { case "Boone": $pcEmail = "[email protected]"; break; case "Charlotte": $pcEmail = "[email protected]"; break; case "Atlanta": $pcEmail = "[email protected]"; break; case "Denver": $pcEmail = "[email protected]"; break; case "Minneapolis": $pcEmail = "[email protected]"; break; case "Orange County": $pcEmail = "[email protected]"; break; default: echo "[email protected]"; } if(isset($_POST["firstName"])) { $firstName = $_POST["firstName"]; } if(isset($_POST["lastName"])) { $lastName = $_POST["lastName"]; } if(isset($_POST["address"])) { $address = $_POST["address"]; } if(isset($_POST["city"])) { $city = $_POST["city"]; } if(isset($_POST["state"])) { $state = $_POST["state"]; } if(isset($_POST["zip"])) { $zip = $_POST["zip"]; } if(isset($_POST["phone"])) { $phone = $_POST["phone"]; } if(isset($_POST["altPhone"])) { $altPhone = $_POST["altPhone"]; } if(isset($_POST["email"])) { $email = $_POST["email"]; } if(isset($_POST["groupType"])) { $groupType = $_POST["groupType"]; } if(isset($_POST["quantity"])) { $quantity = $_POST["quantity"]; } if(isset($_POST["specialRequest"])) { $specialRequest = $_POST["specialRequest"]; } if(isset($_POST["submitDate"])) { $submitDate = $_POST["submitDate"]; } if(isset($_POST["day1"])) { $day1 = $_POST["day1"]; } if(isset($_POST["day2"])) { $day2 = $_POST["day2"]; } if(isset($_POST["day3"])) { $day3 = $_POST["day3"]; } if(isset($_POST["day4"])) { $day4 = $_POST["day4"]; } if(isset($_POST["day5"])) { $day5 = $_POST["day5"]; } if(isset($_POST["day6"])) { $day6 = $_POST["day6"]; } if(isset($_POST["day7"])) { $day7 = $_POST["day7"]; } if(isset($_POST["day8"])) { $day8 = $_POST["day8"]; } if(isset($_POST["day9"])) { $day9 = $_POST["day9"]; } if(isset($_POST["day10"])) { $day10 = $_POST["day10"]; } if(isset($_POST["day11"])) { $day11 = $_POST["day11"]; } if(isset($_POST["day12"])) { $day12 = $_POST["day12"]; } if(isset($_POST["day13"])) { $day13 = $_POST["day13"]; } if(isset($_POST["day14"])) { $day14 = $_POST["day14"]; } if(isset($_POST["day15"])) { $day15 = $_POST["day15"]; } //create day times from form if(isset($_POST["day1TimeStart"]) and isset($_POST["day1TimeEnd"])) { $day1Time = $_POST["day1TimeStart"] ."-". $_POST["day1TimeEnd"]; } if(isset($_POST["day2TimeStart"]) and isset($_POST["day2TimeEnd"])) { $day2Time = $_POST["day2TimeStart"] ."-". $_POST["day2TimeEnd"]; } if(isset($_POST["day3TimeStart"]) and isset($_POST["day3TimeEnd"])) { $day3Time = $_POST["day3TimeStart"] ."-". $_POST["day3TimeEnd"]; } if(isset($_POST["day4TimeStart"]) and isset($_POST["day4TimeEnd"])) { $day4Time = $_POST["day4TimeStart"] ."-". $_POST["day4TimeEnd"]; } if(isset($_POST["day5TimeStart"]) and isset($_POST["day5TimeEnd"])) { $day5Time = $_POST["day5TimeStart"] ."-". $_POST["day5TimeEnd"]; } if(isset($_POST["day6TimeStart"]) and isset($_POST["day6TimeEnd"])) { $day6Time = $_POST["day6TimeStart"] ."-". $_POST["day6TimeEnd"]; } if(isset($_POST["day7TimeStart"]) and isset($_POST["day7TimeEnd"])) { $day7Time = $_POST["day7TimeStart"] ."-". $_POST["day7TimeEnd"]; } if(isset($_POST["day8TimeStart"]) and isset($_POST["day8TimeEnd"])) { $day8Time = $_POST["day8TimeStart"] ."-". $_POST["day8TimeEnd"]; } if(isset($_POST["day9TimeStart"]) and isset($_POST["day9TimeEnd"])) { $day9Time = $_POST["day9TimeStart"] ."-". $_POST["day9TimeEnd"]; } if(isset($_POST["day10TimeStart"]) and isset($_POST["day10TimeEnd"])) { $day10Time = $_POST["day10TimeStart"] ."-". $_POST["day10TimeEnd"]; } if(isset($_POST["day11TimeStart"]) and isset($_POST["day11TimeEnd"])) { $day11Time = $_POST["day11TimeStart"] ."-". $_POST["day11TimeEnd"]; } if(isset($_POST["day12TimeStart"]) and isset($_POST["day12TimeEnd"])) { $day12Time = $_POST["day12TimeStart"] ."-". $_POST["day12TimeEnd"]; } if(isset($_POST["day13TimeStart"]) and isset($_POST["day13TimeEnd"])) { $day13Time = $_POST["day13TimeStart"] ."-". $_POST["day13TimeEnd"]; } if(isset($_POST["day14TimeStart"]) and isset($_POST["day14TimeEnd"])) { $day14Time = $_POST["day14TimeStart"] ."-". $_POST["day14TimeEnd"]; } if(isset($_POST["day15TimeStart"]) and isset($_POST["day15TimeEnd"])) { $day15Time = $_POST["day15TimeStart"] ."-". $_POST["day15TimeEnd"]; } //end time format if ($state == "NC" || $state == "SC") { $foEmail = "[email protected]"; } if ($state == "FL") { $foEmail = "[email protected]"; } if ($state == "OH" || $state == "IN" || $state == "MI" || $state == "WV") { $foEmail = "[email protected]"; } if ($state == "KS" || $state == "IL" || $state == "MO" || $state == "NE" || $state == "OK") { $foEmail = "[email protected]"; } if ($state == "MD" || $state == "DE" || $state == "NJ" || $state == "PA" || $state == "VA" || $state == "DC") { $foEmail = "[email protected]"; } if ($state == "TN" || $state == "AR" || $state == "KY") { $foEmail = "[email protected]"; } if ($state == "NY" || $state == "CT" || $state == "ME" || $state == "MA" || $state == "NH" || $state == "RI" || $state == "VT") { $foEmail = "[email protected]"; } if ($state == "WA" || $state == "ID" || $state == "MT" || $state == "OR" || $state == "AK") { $foEmail = "[email protected]"; } if ($state == "GA" || $state == "AL" || $state == "MS") { $foEmail = "[email protected]"; } if ($state == "CO" || $state == "AZ" || $state == "NM" || $state == "UT" || $state == "WY") { $foEmail = "[email protected]"; } if ($state == "TX" || $state == "LA") { $foEmail = "[email protected]"; } if ($state == "MN" || $state == "IA" || $state == "ND" || $state == "SD" || $state == "WI") { $foEmail = "[email protected]"; } if ($state == "CA" || $state == "HI" || $state == "NV") { $foEmail = "[email protected]"; } //Create an empty message variable. $message = "". "<h2>Extranet Account: <font color=red>$dnnName</font></h2>" . "<h3>Name: <font color=red>$firstName $lastName</font>" . "</h3>" . "<b>Processing Center</b>: $pc" . "<br>" . "<b>Address</b>: $address" . "<br>" . "<b>City</b>: $city" . "<br>" . "<b>State</b>: $state" . "<br>" . "<b>Zip Code</b>: $zip" . "<br>" . "<b>Phone</b>: $phone" . "<br>" . "<b>Alternate Phone</b>: $altPhone" . "<br>" . "<b>Email</b>: $email" . "<br>" . "**********************************************************" . "<br>" . "<b>Group Type</b>: $groupType" . "<br>" . "<b>Number of People in Group</b>: $quantity" . "<br>" . "<b>Special Requests</b>: $specialRequest" . "<br>" . "**********************************************************" . "<br>"; $message = $message."<b>Date(s) Requesting</b>:". "<br>"; if ($day1 == 'Y') {echo $message = $message . "November 24: $day1Time". "<br>";} if ($day2 == 'Y') {echo $message = $message . "November 25: $day2Time" . "<br>";} if ($day3 == 'Y') {echo $message = $message ."November 27: $day3Time" . "<br>";} if ($day4 == 'Y') {echo $message = $message . "November 28: $day4Time" . "<br>" ;} if ($day5 == 'Y') {echo $message = $message . "November 30: $day5Time" . "<br>";} if ($day6 == 'Y') {echo $message = $message . "December 1: $day6Time" . "<br>" ;} if ($day7 == 'Y') {echo $message = $message . "December 2: $day7Time" . "<br>";} if ($day8 == 'Y') {echo $message = $message . "December 3: $day8Time" . "<br>";} if ($day9 == 'Y') {echo $message = $message . "December 4: $day9Time" . "<br>";} if ($day10 == 'Y') {echo $message = $message . "December 5: $day10Time" . "<br>";} if ($day11 == 'Y') {echo $message = $message . "December 8: $day11Time" . "<br>";} if ($day12 == 'Y') {echo $message = $message . "December 9: $day12Time" . "<br>";} if ($day13 == 'Y') {echo $message = $message . "December 10: $day13Time" . "<br>";} if ($day14 == 'Y') {echo $message = $message . "December 11: $day14Time" . "<br>";} if ($day15 == 'Y') {echo $message = $message . "December 12: $day15Time" . "<br>";} echo $message = $message . "<br>"."<div>Please do not reply to this email. If you have any questions, please contact Volunteer Relations.</div>"; //The mail that we want to use to recevie the submitted information. $to= $pcEmail; //The E-Mail subject $subject = "Subject goes here"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type:text/html;charset=iso-8859-1' . "\r\n"; $headers .= "BCC:" .$foEmail."\n"; $headers .= "From: [email protected]". "\r\n"; //Send message by e-mail. mail($to, $subject, $message, $headers); } Link to comment https://forums.phpfreaks.com/topic/164530-php-mail-problem/#findComment-867828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.