2015-04-06 68 views
-1

多個收件人我需要從一個下拉框的每個選擇郵件多個電子郵件地址,但一切我都試過是行不通的。這裏是我使用這個至今需要從電子郵件下拉框

林形式開始

$mailto = $_POST['unit']; 

這是我有下拉框中

<select name="unit" size="1" id="Combobox1"  style="position:absolute;left:43px;top:324px;width:61px;height:21px;z-  index:18;"> 
<option value= '[email protected]'; '[email protected]'> M17</option> 
<option value="[email protected]">M16</option> 
</select> 

的問題,即時通訊有上
1。選項M17它只發送到第一個電子郵件地址
2.它發送的電子郵件地址,而不是單位號碼(M17)
3.需要找出一種方法來編輯通過一個單獨的「用戶友好」頁面的電子郵件地址

</head> 
<body> 
<div id="space"><br></div> 
<div id="container"> 
<div id="wb_Form1"    
<form name="11_Dispatch" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="Form1"> 
<input type="hidden" name="formid" value="form1"> 
<div id="wb_Text1" style="position:absolute;left:10px;top:76px;width:111px;height:16px;z-index:0;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Address</span> </div> 
<input type="text" id="Editbox1" style="position:absolute;left:131px;top:76px;width:198px;height:23px;line-height:23px;z-index:1;" name="LOC" value=""> 
<div id="wb_Text2" style="position:absolute;left:10px;top:106px;width:111px;height:16px;z-index:2;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Subdivision</span></div> 
<input type="text" id="Editbox2" style="position:absolute;left:131px;top:106px;width:198px;height:23px;line-height:23px;z-index:3;" name="SUB" value=""> 
<div id="wb_Text3" style="position:absolute;left:10px;top:136px;width:111px;height:16px;z-index:4;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Call back #  </span></div> 
<input type="text" id="Editbox3" style="position:absolute;left:131px;top:136px;width:198px;height:23px;line-height:23px;z-index:5;" name="#" value=""> 
<div id="wb_Text5" style="position:absolute;left:10px;top:166px;width:111px;height:16px;z-index:6;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Chief Complaint</span></div> 
<input type="text" id="Editbox4" style="position:absolute;left:131px;top:166px;width:198px;height:23px;line-height:23px;z-index:7;" name="CC" value=""> 
<div id="wb_Text6" style="position:absolute;left:10px;top:196px;width:111px;height:16px;z-index:8;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Pt name</span> </div> 
<input type="text" id="Editbox5" style="position:absolute;left:131px;top:196px;width:198px;height:23px;line-height:23px;z-index:9;" name="NAME" value=""> 
<div id="wb_Text7" style="position:absolute;left:10px;top:226px;width:111px;height:16px;z-index:10;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Pt Age</span> </div> 
<input type="text" id="Editbox6" style="position:absolute;left:131px;top:226px;width:198px;height:23px;line-height:23px;z-index:11;" name="AGE" value=""> 
<div id="wb_Text9" style="position:absolute;left:10px;top:256px;width:111px;height:16px;z-index:12;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Callers Name</span></div> 
<input type="text" id="Editbox7" style="position:absolute;left:131px;top:256px;width:198px;height:23px;line-height:23px;z-index:13;" name="CALLER" value=""> 
<div id="wb_Text10" style="position:absolute;left:10px;top:286px;width:111px;height:16px;z-index:14;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:13px;">Identifying Factors</span></div> 
<input type="text" id="Editbox8" style="position:absolute;left:131px;top:286px;width:198px;height:23px;line-height:23px;z-index:15;" name="NOTES" value=""> 
<input type="submit" id="Button2" name="" value="Dispatch" style="position:absolute;left:169px;top:357px;width:96px;height:25px;z-index:16;"> 
<div id="wb_Text12" style="position:absolute;left:166px;top:30px;width:133px;height:22px;z-index:17;text-align:left;"> 
<span style="color:#000000;font-family:Arial;font-size:19px;"><strong>911 Dispatch</strong></span></div> 
<select name="unit" size="1" id="Combobox1" style="position:absolute;left:43px;top:324px;width:61px;height:21px;z-index:18;"> 
<option value="M17">M17 </option> 
<option value="M16">M16</option> 
<option value="M15">M15</option> 
<option value="M14">M14</option> 
<option value="M11">M11</option> 
<option value="M10">M10</option> 
<option value="M07">M07</option> 
</select> 
</form> 
+0

從您的選擇和我們刪除的電子郵件地址e改爲PHP中的數組;只要讓他們選擇M17,並使用'isset()'。你也不應該向他人展示電子郵件地址是什麼,他們肯定會被髮送垃圾郵件。 – 2015-04-06 02:47:56

+0

弗雷德我搜索了谷歌它....我無法找到任何作品....我發誓我已經嘗試了一切......除了一個數組,只是因爲我沒有數組的實驗,並沒有線索在哪裏開始。任何指針?感謝您提前幫助 – JPOLK 2015-04-06 03:31:27

回答

0

正如建議,不要把你的to地址的形式。這僅僅是基本的和mail()部分是直接從手動 - >http://php.net/manual/en/function.mail.php例4中發送HTML電子郵件顯示多個電子郵件收件人使用串聯不過,我使用的內爆):

PHP:

if(isset($_POST['unit'])) { 
    // Store emails in the code or database to draw from: 
    // Personally I like to store this in an array (if I were to hardcode it) 
    // Reason being, is that if you suddenly one day get access to a database 
    // and you draw a bunch of email addresses from that database, those emails 
    // would likely be listed as an array. 

    // By storing each email in a same-named array, you basically 
    // create an easy-to-read mailing list 
    $units['m17'][] = '[email protected]'; 
    $units['m17'][] = '[email protected]'; 
    $units['m16'][] = '[email protected]'; 

    // if the <select> value of $_POST['unit'] equals 'm17' 
    // $units[$_POST['unit']] then is the same as $units['m17'] 
    $to  = implode(",",$units[$_POST['unit']]); 
    $subject = 'the subject'; 
    $message = 'hello'; 
    $headers = 'From: [email protected]'."\r\n"; 

    // As noted in the PHP Manual, the function implode() takes an array 
    // and combines the values into a string with a "glue", in this case a comma 
    // $to would then equal: "[email protected],[email protected]" if 
    // $_POST['unit'] equals 'm17'. 
    mail($to, $subject, $message, $headers); 
} 

FORM:

<select name="unit" size="1" id="Combobox1" style="position: absolute; left: 43px; top: 324px; width: 61px; height: 21px; z-index: 18;"> 
    <option value="m17">M17</option> 
    <option value="m16">M16</option> 
</select> 
+0

,這很好用!一個問題,我如何讓我的表單成爲消息?它之前做過,但是在我添加代碼之後,它不再將它作爲消息發送出去? – JPOLK 2015-04-06 07:12:48

+0

我不知道你有什麼消息。你將分配'$ message'你的表單信息。現在'$ message ='hello';'在我的示例中 – Rasclatt 2015-04-06 07:14:59

+0

應該只是表單名稱的權利?或者它需要[] – JPOLK 2015-04-06 07:21:43