I have a ZC website that has several pages of custom forms. I would like all the forms to be handled on the same page instead of separate ones.
I am looking for a new set of eyes as I can’t figure out why this doesn’t send out the emails.
Using the $current_page_base; variable I create a session on each of the form pages.
$_SESSION['pageCameFrom'] = $current_page_base;
ON my results page I have this code. It has been tested and works correctly.
Testing the email handling code without it being inside of the “page came from code”, the results page emails the variables out and displays the thank you message correctly.Code:<?php $pageCameFrom = ""; $pageCameFrom = $_SESSION['pageCameFrom']; if ($pageCameFrom == "semi_trailer_tarp_quote") { echo "semi_trailer_tarp_quote page!"; } elseif ($pageCameFrom == "fertilizer_quote") { echo "fertilizer_quote page!"; } elseif ($pageCameFrom == "farm_truck_quote") { echo "farm_truck_quote page!"; } elseif ($pageCameFrom == "belly_dump_quote") { echo "belly_dump_quote page!"; } elseif ($pageCameFrom == "grain_cart_quote") { echo "grain_cart_quote page!"; } elseif ($pageCameFrom == "replacement_tarp_quote") { echo "replacement_tarp_quote page!"; } else { echo "You must submit a tarp quote form to get the results."; } ?>
When I add the email code inside of the if elseif code, that is when the results page doesn’t email the results. Any ideas???Code:<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $subject = SemiTrailerTarpQuoteValidation($_POST["subject"]); $SemiOrPup = SemiTrailerTarpQuoteValidation($_POST["SemiOrPup"]); $TypeOfTarpSystem = SemiTrailerTarpQuoteValidation($_POST["TypeOfTarpSystem"]); $Bows = SemiTrailerTarpQuoteValidation($_POST["Bows"]); $EndCapMaterial = SemiTrailerTarpQuoteValidation($_POST["EndCapMaterial"]); $Rise = SemiTrailerTarpQuoteValidation($_POST["Rise"]); $FrontEndCap = SemiTrailerTarpQuoteValidation($_POST["FrontEndCap"]); $RearEndCap = SemiTrailerTarpQuoteValidation($_POST["RearEndCap"]); $ROLTECendcapDepth = SemiTrailerTarpQuoteValidation($_POST["ROLTECendcapDepth"]); $EZLOCboltonBracket = SemiTrailerTarpQuoteValidation($_POST["EZLOCboltonBracket"]); $EndCapOption = SemiTrailerTarpQuoteValidation($_POST["EndCapOption"]); $RearFillerOption = SemiTrailerTarpQuoteValidation($_POST["RearFillerOption"]); $TarpFabric = SemiTrailerTarpQuoteValidation($_POST["TarpFabric"]); $TarpColor = SemiTrailerTarpQuoteValidation($_POST["TarpColor"]); $AUpperBoxLength = SemiTrailerTarpQuoteValidation($_POST["AUpperBoxLength"]); $A1TaperedUpperLength = SemiTrailerTarpQuoteValidation($_POST["A1TaperedUpperLength"]); $A3Front = SemiTrailerTarpQuoteValidation($_POST["A3Front"]); $A2TaperedLowerLength = SemiTrailerTarpQuoteValidation($_POST["A2TaperedLowerLength"]); $A4Rear = SemiTrailerTarpQuoteValidation($_POST["A4Rear"]); $BUpperBoxWidth = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidth"]); $BUpperBoxWidthInFront = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInFront"]); $BUpperBoxWidthInMiddle = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInMiddle"]); $BUpperBoxWidthInRear = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInRear"]); $CBoxHeight = SemiTrailerTarpQuoteValidation($_POST["CBoxHeight"]); $DTopRailWidth = SemiTrailerTarpQuoteValidation($_POST["DTopRailWidth"]); $EInsideBoxWidth = SemiTrailerTarpQuoteValidation($_POST["EInsideBoxWidth"]); $CornerConfiguration = SemiTrailerTarpQuoteValidation($_POST["CornerConfiguration"]); $FOutsideCornerRadius = SemiTrailerTarpQuoteValidation($_POST["FOutsideCornerRadius"]); $GFlatAcrossFront = SemiTrailerTarpQuoteValidation($_POST["GFlatAcrossFront"]); $HFlatAcrossDiagonal = SemiTrailerTarpQuoteValidation($_POST["HFlatAcrossDiagonal"]); $IDiagonalDepth = SemiTrailerTarpQuoteValidation($_POST["IDiagonalDepth"]); $Company = SemiTrailerTarpQuoteValidation($_POST["Company"]); $Contact = SemiTrailerTarpQuoteValidation($_POST["Contact"]); $Address = SemiTrailerTarpQuoteValidation($_POST["Address"]); $City = SemiTrailerTarpQuoteValidation($_POST["City"]); $State = SemiTrailerTarpQuoteValidation($_POST["State"]); $ZIP = SemiTrailerTarpQuoteValidation($_POST["ZIP"]); $email = SemiTrailerTarpQuoteValidation($_POST["email"]); $Phone = SemiTrailerTarpQuoteValidation($_POST["Phone"]); $Fax = SemiTrailerTarpQuoteValidation($_POST["Fax"]); $BoxTrailer = SemiTrailerTarpQuoteValidation($_POST["BoxTrailer"]); $ContactPreference = SemiTrailerTarpQuoteValidation($_POST["ContactPreference"]); } function SemiTrailerTarpQuoteValidation($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $sender = '[email protected]'; $recipient = '[email protected]'; $message = "Subject: $subject Semi Or Pup: $SemiOrPup Type Of Tarp System: $TypeOfTarpSystem Bows: $Bows End Cap Material: $EndCapMaterial Rise: . $Rise Front End Cap: $FrontEndCap Rear End Cap: $RearEndCap ROLTEC end cap Depth: $ROLTECendcapDepth EZLOC bolton Bracket: $EZLOCboltonBracket End Cap Option: $EndCapOption Rear Filler Option: $RearFillerOption Tarp Fabric: $TarpFabric Tarp Color: $TarpColor A-Upper Box Length: $AUpperBoxLength A1-Tapered Upper Length: $A1TaperedUpperLength A2-Tapered Lower Length: $A2TaperedLowerLength A3-Front: $A3Front A4-Rear: $A4Rear B-Upper Box Width: $BUpperBoxWidth B-Upper Box Width In Front: $BUpperBoxWidthInFront B-Upper Box Width In Middle: $BUpperBoxWidthInMiddle B-Upper Box Width In Rear: $BUpperBoxWidthInRear C-Box Height: $CBoxHeight D-Top Rail Width: $DTopRailWidth E-Inside Box Width: $EInsideBoxWidth Corner Configuration: $CornerConfiguration F-Outside Corner Radius: $FOutsideCornerRadius G-Flat Across Front: $GFlatAcrossFront H-Flat Across Diagonal: $HFlatAcrossDiagonal I-Diagonal Depth: $IDiagonalDepth Company: $Company Contact: $Contact Address: $Address City: $City State: $State ZIP: $ZIP Email: $email Phone: $Phone Fax: $Fax Box Trailer: $BoxTrailer Contact Preference: . $ContactPreference"; //$message = wordwrap($message, 70, "\r\n"); //$headers .= "MIME-Version: 1.0\r\n"; //$headers .= "Content-type: text/html; charset: utf8\r\n"; $headers .= 'From:' . $sender; if (mail($recipient, $subject, $message, $headers)) { echo "Thank you for getting in touch!<br> We appreciate you contacting us about $subject. One of our colleagues will get back to you shortly.<br> Have a great day!"; } else { echo "Error: Message not accepted"; } ?>
Code:<?php $pageCameFrom = ""; $pageCameFrom = $_SESSION['pageCameFrom']; if ($pageCameFrom == "semi_trailer_tarp_quote") { if ($_SERVER["REQUEST_METHOD"] == "POST") { $subject = SemiTrailerTarpQuoteValidation($_POST["subject"]); $SemiOrPup = SemiTrailerTarpQuoteValidation($_POST["SemiOrPup"]); $TypeOfTarpSystem = SemiTrailerTarpQuoteValidation($_POST["TypeOfTarpSystem"]); $Bows = SemiTrailerTarpQuoteValidation($_POST["Bows"]); $EndCapMaterial = SemiTrailerTarpQuoteValidation($_POST["EndCapMaterial"]); $Rise = SemiTrailerTarpQuoteValidation($_POST["Rise"]); $FrontEndCap = SemiTrailerTarpQuoteValidation($_POST["FrontEndCap"]); $RearEndCap = SemiTrailerTarpQuoteValidation($_POST["RearEndCap"]); $ROLTECendcapDepth = SemiTrailerTarpQuoteValidation($_POST["ROLTECendcapDepth"]); $EZLOCboltonBracket = SemiTrailerTarpQuoteValidation($_POST["EZLOCboltonBracket"]); $EndCapOption = SemiTrailerTarpQuoteValidation($_POST["EndCapOption"]); $RearFillerOption = SemiTrailerTarpQuoteValidation($_POST["RearFillerOption"]); $TarpFabric = SemiTrailerTarpQuoteValidation($_POST["TarpFabric"]); $TarpColor = SemiTrailerTarpQuoteValidation($_POST["TarpColor"]); $AUpperBoxLength = SemiTrailerTarpQuoteValidation($_POST["AUpperBoxLength"]); $A1TaperedUpperLength = SemiTrailerTarpQuoteValidation($_POST["A1TaperedUpperLength"]); $A3Front = SemiTrailerTarpQuoteValidation($_POST["A3Front"]); $A2TaperedLowerLength = SemiTrailerTarpQuoteValidation($_POST["A2TaperedLowerLength"]); $A4Rear = SemiTrailerTarpQuoteValidation($_POST["A4Rear"]); $BUpperBoxWidth = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidth"]); $BUpperBoxWidthInFront = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInFront"]); $BUpperBoxWidthInMiddle = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInMiddle"]); $BUpperBoxWidthInRear = SemiTrailerTarpQuoteValidation($_POST["BUpperBoxWidthInRear"]); $CBoxHeight = SemiTrailerTarpQuoteValidation($_POST["CBoxHeight"]); $DTopRailWidth = SemiTrailerTarpQuoteValidation($_POST["DTopRailWidth"]); $EInsideBoxWidth = SemiTrailerTarpQuoteValidation($_POST["EInsideBoxWidth"]); $CornerConfiguration = SemiTrailerTarpQuoteValidation($_POST["CornerConfiguration"]); $FOutsideCornerRadius = SemiTrailerTarpQuoteValidation($_POST["FOutsideCornerRadius"]); $GFlatAcrossFront = SemiTrailerTarpQuoteValidation($_POST["GFlatAcrossFront"]); $HFlatAcrossDiagonal = SemiTrailerTarpQuoteValidation($_POST["HFlatAcrossDiagonal"]); $IDiagonalDepth = SemiTrailerTarpQuoteValidation($_POST["IDiagonalDepth"]); $Company = SemiTrailerTarpQuoteValidation($_POST["Company"]); $Contact = SemiTrailerTarpQuoteValidation($_POST["Contact"]); $Address = SemiTrailerTarpQuoteValidation($_POST["Address"]); $City = SemiTrailerTarpQuoteValidation($_POST["City"]); $State = SemiTrailerTarpQuoteValidation($_POST["State"]); $ZIP = SemiTrailerTarpQuoteValidation($_POST["ZIP"]); $email = SemiTrailerTarpQuoteValidation($_POST["email"]); $Phone = SemiTrailerTarpQuoteValidation($_POST["Phone"]); $Fax = SemiTrailerTarpQuoteValidation($_POST["Fax"]); $BoxTrailer = SemiTrailerTarpQuoteValidation($_POST["BoxTrailer"]); $ContactPreference = SemiTrailerTarpQuoteValidation($_POST["ContactPreference"]); } function SemiTrailerTarpQuoteValidation($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $sender = '[email protected]'; $recipient = '[email protected]'; $message = "Subject: $subject Semi Or Pup: $SemiOrPup Type Of Tarp System: $TypeOfTarpSystem Bows: $Bows End Cap Material: $EndCapMaterial Rise: . $Rise Front End Cap: $FrontEndCap Rear End Cap: $RearEndCap ROLTEC end cap Depth: $ROLTECendcapDepth EZLOC bolton Bracket: $EZLOCboltonBracket End Cap Option: $EndCapOption Rear Filler Option: $RearFillerOption Tarp Fabric: $TarpFabric Tarp Color: $TarpColor A-Upper Box Length: $AUpperBoxLength A1-Tapered Upper Length: $A1TaperedUpperLength A2-Tapered Lower Length: $A2TaperedLowerLength A3-Front: $A3Front A4-Rear: $A4Rear B-Upper Box Width: $BUpperBoxWidth B-Upper Box Width In Front: $BUpperBoxWidthInFront B-Upper Box Width In Middle: $BUpperBoxWidthInMiddle B-Upper Box Width In Rear: $BUpperBoxWidthInRear C-Box Height: $CBoxHeight D-Top Rail Width: $DTopRailWidth E-Inside Box Width: $EInsideBoxWidth Corner Configuration: $CornerConfiguration F-Outside Corner Radius: $FOutsideCornerRadius G-Flat Across Front: $GFlatAcrossFront H-Flat Across Diagonal: $HFlatAcrossDiagonal I-Diagonal Depth: $IDiagonalDepth Company: $Company Contact: $Contact Address: $Address City: $City State: $State ZIP: $ZIP Email: $email Phone: $Phone Fax: $Fax Box Trailer: $BoxTrailer Contact Preference: . $ContactPreference"; //$message = wordwrap($message, 70, "\r\n"); //$headers .= "MIME-Version: 1.0\r\n"; //$headers .= "Content-type: text/html; charset: utf8\r\n"; $headers .= 'From:' . $sender; if (mail($recipient, $subject, $message, $headers)) { echo "Thank you for getting in touch!<br> We appreciate you contacting us about $subject. One of our colleagues will get back to you shortly.<br> Have a great day!"; } else { echo "Error: Message not accepted"; } } elseif ($pageCameFrom == "fertilizer_quote") { echo "fertilizer_quote page!"; } elseif ($pageCameFrom == "farm_truck_quote") { echo "farm_truck_quote page!"; } elseif ($pageCameFrom == "belly_dump_quote") { echo "belly_dump_quote!"; } elseif ($pageCameFrom == "grain_cart_quote") { echo "grain_cart_quote page!"; } elseif ($pageCameFrom == "replacement_tarp_quote") { echo "replacement_tarp_quote page!"; } else { echo "You must submit a tarp quote form to get the results."; } //$_SESSION['pageCameFrom']=""; ?>


Reply With Quote
