Chad Muska
New member
I have an html web form that once submitted activates a script which directs the user to a page based on their selection. The script also sends the admin the message.
Now, what I would like to do is send the user one of two emails. The email sent will be based on the selection. For instance if the user selects "w," the user will get email A. If the user chooses "g" or "o" they will get a email B. How do i do this? What do I add to the code? Thanks in advance
Here is my code so far:
<?php
$se = $_POST['se'];
$seURL = '';
switch ($se) {
case 'W':
$seURL = "google.com";
break;
case 'G':
$seURL = "yahoo.com";
break;
case 'O':
$seURL = "yahoo.com";
break;
default:
$seURL = "";
}
if ($seURL != "") {
/* Redirect browser */
/* make sure nothing is output to the page before this statement */
header("Location: " . $seURL);
}
// get posted data into local variables
$EmailFrom = "[email protected]"; //Set who the email comes from here!
$EmailTo = "[email protected] , [email protected]"; //Set where the email gets sent to!
$Subject = "User info form"; //Set subject of email!
$first_name = Trim(stripslashes($_POST['first_name']));
$last_name = Trim(stripslashes($_POST['last_name']));
$phone = Trim(stripslashes($_POST['phone']));
$email = Trim(stripslashes($_POST['email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "first_name: ";
$Body .= $first_name;
$Body .= "\n";
$Body .= "last_name: ";
$Body .= $last_name;
$Body .= "\n";
$Body .= "phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "email: ";
$Body .= $email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
?>
Now, what I would like to do is send the user one of two emails. The email sent will be based on the selection. For instance if the user selects "w," the user will get email A. If the user chooses "g" or "o" they will get a email B. How do i do this? What do I add to the code? Thanks in advance
Here is my code so far:
<?php
$se = $_POST['se'];
$seURL = '';
switch ($se) {
case 'W':
$seURL = "google.com";
break;
case 'G':
$seURL = "yahoo.com";
break;
case 'O':
$seURL = "yahoo.com";
break;
default:
$seURL = "";
}
if ($seURL != "") {
/* Redirect browser */
/* make sure nothing is output to the page before this statement */
header("Location: " . $seURL);
}
// get posted data into local variables
$EmailFrom = "[email protected]"; //Set who the email comes from here!
$EmailTo = "[email protected] , [email protected]"; //Set where the email gets sent to!
$Subject = "User info form"; //Set subject of email!
$first_name = Trim(stripslashes($_POST['first_name']));
$last_name = Trim(stripslashes($_POST['last_name']));
$phone = Trim(stripslashes($_POST['phone']));
$email = Trim(stripslashes($_POST['email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "first_name: ";
$Body .= $first_name;
$Body .= "\n";
$Body .= "last_name: ";
$Body .= $last_name;
$Body .= "\n";
$Body .= "phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "email: ";
$Body .= $email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
?>