Forum Moderators: coopster
I'm pretty much a newbie to php, but learning quickly (there's nothing like trial by fire!) ;)
My client wants a simple form on her site, which emails the user's answers to her. Sounds simple enough--but, she wants the user's email to be picked up by the form and placed in the "from" field on the email. This is where I'm having problems. I can get the form to send and everything is appearing in the email except the from field shows "client@clientsservername.com" instead of the email address which was typed into the form.
Here's the code I'm using right now:
<?php
// ************Begin Configure***************
//Put your subject in here
$subject = "form submission";
// ************End Configure****************
$message = "";
foreach($HTTP_POST_VARS as $key => $value)
{
$message .= $key . ":" . $value . "\n";
}
mail('me@mydomain.com', $subject, $message, $email);
?>
I've also tried defining $from = "From: $email"; and changing the mail line to:
mail('me@mydomain.com', $subject, $message, $from);
This changes the from field in the email to $email@servername.com
Any help with this would be greatly appreciated!
$to = "me@mydomain.com";
$subject = "Form Submission";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "From: $email <$email>\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
make sure that the $email variable is the same as the name as the form field or variable if you have it predefined
I think this should work.