Wondering if anyone know how to automatically send the user an email after he/she fills out a form. I have the form emailed to me after it gets submitted, but I can't figure out how to capture the user's email from the form field and have it send it to them automatically???
Here is some code that I use to send the mail:
//mail the message before redirecting
if($_POST['dosend'] == "yes"){
// The message
$headers = "From: no-reply@domain.com";
$message = "NEW Message :: ".$_POST['event_name']." \n Email: ".$_POST['email']." \n Click link to http://www.domain.com/admin/ Approve this Event!";
// Send
mail('me@me.com', 'New :: Calendar Message', $message, $headers);
}
//end mail
Retrieve it from one of the $_POST
variables:
// HTML
<input type="text" name="email" />
// PHP (you might want to check if it's valid too)
$user_email = $_POST['email'];
mail($user_email, 'New :: Calendar Message', $message, $headers);
You can also add yourself as BCC, so you only have to call the mail()
function once:
$headers = "From: no-reply@domain.com \n" .
"Bcc: You \n";
mail($user_email, 'New :: Calendar Message', $message, $headers);
如果用户将其放在表单中,则它应该在发布字段之一中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.