IShiva
asked on
Form to email but also with 'thank you' email to user
Hey guys and gals
I have very little php experience so your help is greatly appreciated. I have a php script that sends an email to us when someone fills out our online form.
I would like to also send a 'Thank You' email to the user that just filled out the form. Can you add some code to what Ive got to accomplish this?
Thanks so much!
<?php
$EmailFrom = Trim(stripslashes($_POST[' EmailFrom' ]));
$EmailTo = "me@mydomain.com";
$Subject = "Tryout Form Submission";
$name = Trim(stripslashes($_POST[' name']));
$comments = Trim(stripslashes($_POST[' comments'] ));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html \">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $EmailFrom;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ThankYou.h tml\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html \">";
}
?>
I have very little php experience so your help is greatly appreciated. I have a php script that sends an email to us when someone fills out our online form.
I would like to also send a 'Thank You' email to the user that just filled out the form. Can you add some code to what Ive got to accomplish this?
Thanks so much!
<?php
$EmailFrom = Trim(stripslashes($_POST['
$EmailTo = "me@mydomain.com";
$Subject = "Tryout Form Submission";
$name = Trim(stripslashes($_POST['
$comments = Trim(stripslashes($_POST['
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $EmailFrom;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $comments;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ThankYou.h
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
IShiva