2009-12-15 52 views
0

我創建了以下代碼,因此當用戶選擇一個部門(銷售部門,帳單,市場營銷部門,財務部門等)並使用我創建的聯繫人表單時,電子郵件將發送給公司中的適當人員。switch case語句是否靈活?

<?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; 
} 

?> 

當客戶端接收電子郵件的發件人:字段狀態發件人的電子郵件,這是罰款,除了技術支持部門的所有部門。該部門需要事先知道發件人的電子郵件,因此我需要對其進行編碼,因此,當選擇技術選項並收到電子郵件時,該地址是默認地址(即[email protected])。

不知道如何做到這一點,如果這可以使用switch/case語句來完成?

回答

0

我可能只是在這裏失去了一些東西,但你能不能只替換:

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

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

開關罩內?

+0

謝謝!我是新手,因此我不確定我在哪裏以及如何聲明$ technical_emailaddress等於什麼。 我試過在頂部,如下圖所示...但這並沒有工作 $ 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]']; 感謝幫助! 歡呼聲, chaser – chaser7016 2009-12-15 15:39:23

相關問題