Hi
I have created the following code so when a user chooses a department (Sales, Billing, Marketing, Finance, etc) and uses the contact form I created, the e-mail is sent to the proper person in the company.
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attention'];
$prefphone = $_POST['phone'];
$contact_pref = $_POST['contact'];
$subject = $_POST['subject'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attention = $attention ;
$subject = $attention;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
From: $visitor ($visitormail)\n
Please contact me by: $contact \n
Phone Number: $phone \n
Subject: $subject \n
Message: $notes \n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
switch ($attention) {
case "Residential":
mail("[email protected]", $subject, $message, $from);
break;
case "Billing":
mail("[email protected]", $subject, $message, $from);
break;
case "Service":
mail("[email protected]", $subject, $message, $from);
break;
case "Technical":
mail("[email protected]", $subject, $message, $from);
break;
}
?>
When the client receives the email the from: field states the sender's email, which is fine for all departments except the Technical-Support department. This department needs to know the sender's email before hand and thus I need to code it so when technical option is chosen and they receive an email, the address is a default one (i.e. [email protected]).
Not sure how to do this and if this can be done using the switch/case statement?
thanks,
chaser