paramaniac Posted September 26, 2007 Share Posted September 26, 2007 I've not been using PHP for long and have started using a handy contact form script which sends data from a HTML form to an email address. What I would like to do is send TWO emails from the same script. 1 to the website owner with the info from the HTML form, and another to the form user as an autoresponse. Here is the script below. It currently just sends the info submitted on the HTML form to an email address. How can I make it send an email to the form user too? Any help much appreciated! <?php // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['email'])); $EmailTo = "owner@website.com"; $Subject = "Contact form"; $fullname = Trim(stripslashes($_POST['fullname'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $enquiry = Trim(stripslashes($_POST['enquiry'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Full Name: "; $Body .= $fullname; $Body .= "\n"; $Body .= "Email Address: "; $Body .= $email; $Body .= "\n"; $Body .= "Telephone number: "; $Body .= $telephone; $Body .= "\n"; $Body .= "Enquiry details: "; $Body .= $enquiry; $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=ok.htm\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70738-need-help-with-contact-formemail-script/ Share on other sites More sharing options...
AdRock Posted September 26, 2007 Share Posted September 26, 2007 What about adding this line. Haven't checked it but the theory works $success1 = mail($EmailFrom, $Subject, $Body, "From: <$EmailFrom>"); underneath $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); Quote Link to comment https://forums.phpfreaks.com/topic/70738-need-help-with-contact-formemail-script/#findComment-355648 Share on other sites More sharing options...
paramaniac Posted September 26, 2007 Author Share Posted September 26, 2007 It works! So simple! Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/70738-need-help-with-contact-formemail-script/#findComment-355837 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.