Jump to content

Recommended Posts

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\">";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/70738-need-help-with-contact-formemail-script/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.