Goon Posted September 9, 2008 Share Posted September 9, 2008 I'm using a script which sends a submitted contact us form to a designated email address. The problem is when I submit the form, although the email is sent, all the user sees is a blank screen. Can anyone help me with the code I need to display a 'thank you' message, preferably on the same page that the contact us form was submitted. Thanks Existing script code <?php $ToEmail = 'info@allvech.com'; $EmailSubject = 'Site contact form '; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["Name"]."<br>"; $MESSAGE_BODY .= "Phone Number: ".$_POST["PhoneNumber"]."<br>"; $MESSAGE_BODY .= "Type of Vehicle: ".$_POST["VehicleType"]."<br>"; $MESSAGE_BODY .= "Problem Description: ".nl2br($_POST["Description"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> _______________________________________________________________________________ Contact us form <html> <head> <title>AllVech</title> <?php include("site_html_head.php"); ?> </head> <body> <?php include("site_banner.php"); ?> <?php include("site_content_start.php"); ?> <?php // place the content here ?> <h1>Contact Us</h1> <form method="post" action="script_contactus.php"> <input type="hidden" name="check_submit" value="1" /> <table cellpadding=5 cellspacing=0 border=0> <tr> <td class="tdb">Name:</td> <td><input type="text" name="Name" id="Name" value=""></td> </tr> <tr> <td class="tdb">Phone number:</td> <td><input type="text" name="PhoneNumber" id="PhoneNumber" value=""></td> </tr> <tr> <td class="tdb">Type of vehicle:</td> <td> <select name="VehicleType" id="VehicleType"> <option>Car</option> <option>Van</option> <option>Truck</option> <option>Bus</option> </select> </td> </tr> <tr> <td class="tdb">Problem Description:</td> <td><textarea name="Description" id="Description" rows=6 cols=50></textarea></td> </tr> <tr> <td><br></td> <td><input name="Submit" type="submit" id="Submit" value="Submit"/></td> </tr> </table> </form> <br> <p>Our mechanics can also be reached 24 hours a day<br> T: 0872555410<br> E: <a href="mailto:info@allvech.ie.ie">info@allvech.ie</a><br> </p> <?php include("site_content_end.php"); ?> <?php include("site_footer.php"); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/ Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2008 Share Posted September 9, 2008 put whatever HTML you want after the PHP closing tag ?> it will display just like regular HTML after the mail() function call. Quote Link to comment https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/#findComment-637461 Share on other sites More sharing options...
JonnoTheDev Posted September 9, 2008 Share Posted September 9, 2008 You are better redirecting the user to a success page with a header command after the email has been sent header("Location: successpage.php"); If you add HTML under the mail() function and the user hits refresh then the email with get set again, and again, and again........ Quote Link to comment https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/#findComment-637574 Share on other sites More sharing options...
revraz Posted September 9, 2008 Share Posted September 9, 2008 He wouldn't be able to use Header since there is output to the browser, he would have to use HTML or Javascript to redirect. Quote Link to comment https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/#findComment-637589 Share on other sites More sharing options...
Goon Posted September 9, 2008 Author Share Posted September 9, 2008 Thanks for your help guys Quote Link to comment https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/#findComment-637658 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.