Log in

View Full Version : Adding Auto Reply



Hemjesti
08-20-2010, 04:39 PM
Hey everybody - thanks in advance for any assistance you can provide.

I have this form, and it submits just fine - however, i now need it to send the submitter a copy of the email and some additional information.

can you PLEASE help me with this?

Here's the php form code:

<?php

$EmailFrom = "Win One";
$EmailTo = "sales@capsonewire.com";
$Subject = "Registration";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$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=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

bluewalrus
08-20-2010, 05:36 PM
Can't you just add another mail function in?

The PHP header function will work better than the meta redirect as well http://php.net/manual/en/function.header.php

Hemjesti
08-20-2010, 06:04 PM
i am not a coder by any means and my boss threw me under the bus to add an auto reply to this form. I've figured out that this is the code that the form uses to process - but now i have NO IDEA what to do. Mail function, header, meta, no idea what all that means....

bluewalrus
08-20-2010, 07:26 PM
Okay, disregard headers and meta info than and try this...



<?php

$EmailFrom = "Win One";
$EmailTo = "sales@capsonewire.com";
$Subject = "Registration";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

//Auto send
$Auto_Subject = 'Auto_Response';
$Auto_Body = 'Auto filled email';
$Auto_From = 'computer_talks@computer.com';
if (mail($Email, $Auto_Subject, $Auto_Body, "From: <$Auto_From>") {
echo "sent";
} else {
echo "Not";
}


// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Hemjesti
08-20-2010, 09:37 PM
Thanks guys but I was helped by the phenom over at PHP Freaks (http://www.phpfreaks.com). they were sooooo fast and helpful and didn't make me feel like the idiot i am when it comes to this stuff. Sorry for wasting your time.