views:

114

answers:

1

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

A: 

I may just be missing something here, but can you not just replace:

case "Technical":
        mail("[email protected]", $subject, $message, $from);
        break;

with

case "Technical":
        mail("[email protected]", $subject, $message, $technical_emailaddress);
        break;

within the switch case?

Thank you! I'm a newbie and thus I'm not sure where and how I declare what $technical_emailaddress equals.I tried at the top, as seen below ... but that did not work$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'];$technical_emailaddress = $_POST['[email protected]'];Appreciate the help!cheers,chaser
Jonah1289