Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Form working but not working?

10:25 am on May 24, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 30, 2009
votes: 0

Hello, I use a php script to grab info submitted into a form, this been used as a general contact form, however.

Every thing works, mail comes through with correct details on, the issue I have the script doesn't put the recipents email address in the header or where ever, so when it comes to replying there isn't an email address.

I hope that makes sense and help would be great

below is my code
/* Set e-mail recipient */
$myemail = "myemail@myemail.com";
$subject = "Order Enquiry";

/* Check all form inputs using check_input function */
$name = check_input($_POST['name'], "name");
$email = check_input($_POST['email'], "email");
$address = check_input($_POST['address'], "address");
$postcode = check_input($_POST['postcode'], "postcode");
$product = check_input($_POST['product'], "product");
$size = check_input($_POST['size'], "size");
$info = check_input($_POST['info'], "info");
$telephone = check_input($_POST['telephone'], "telephone");
$bestway = check_input($_POST['bestway'], "bestway");
$nature = check_input($_POST['nature'], "nature");
$how = check_input($_POST['how'], "how");

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
show_error("E-mail address not valid");

/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
$website = '';

/* Let's prepare the message for the e-mail */
$message = "Hello!

Your contact form has been submitted by:

Name: $name
E-mail: $email
Address: $address
Postcode: $postcode
Product Type: $product
Required Size: $size
More Info: $info
Telephone: $telephone
Best Way: $bestway
Nature of Contact: $nature
Found by: $how


/* Send the message using mail() function */
mail($myemail, $subject, $message,);

/* Redirect visitor to the thank you page */
header('Location: thank-you.htm');

/* Functions we used */
function check_input($data, $problem='')
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
return $data;

function show_error($myError)

<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

11:06 am on May 24, 2011 (gmt 0)

Junior Member

joined:Apr 27, 2011
votes: 0

Just change the line

mail($myemail, $subject, $message,);

to something like

mail($myemail, $subject, $message, "From: \"$name\" <$email>\r\nReply-To: $email");
11:22 am on May 24, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 30, 2009
votes: 0

LEGEND, thank you, I have been trying all sorts, appreciated your help.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members