Jump to content

Recommended Posts

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>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/123428-solved-contact-us-form-response/
Share on other sites

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........

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.