homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Form working but not working?
davidh6781




msg:4316799
 10:25 am on May 24, 2011 (gmt 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
<?php
/* 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

Regards
";

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

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

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

function show_error($myError)
{
?>
<html>
<body>

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

</body>
</html>
<?php
exit();
}
?>

 

agent_x




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

Just change the line

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

to something like

mail($myemail, $subject, $message, "From: \"$name\" <$email>\r\nReply-To: $email");

davidh6781




msg:4316815
 11:22 am on May 24, 2011 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved