0

我正在尝试设置一个简单的 PHP 联系人,问题是当我从 Multiple List 中选择一个值时,我得到了ARRAY。结果在电子邮件收件箱中,而不是以下值:查询主题:数组

              <SELECT class=matter multiple size=3 
              name=subject[]>
                        <OPTION value="ACMI / Wet Lease">ACMI / Wet 
                          Lease</OPTION>
                        <OPTION value="Dry Lease">Dry Lease</OPTION>
                        <OPTION value="Charter Services">Charter Services</OPTION>
                        <OPTION value="Religious Pilgrimage">Religious 
                          Pilgrimage</OPTION>
                        <OPTION 
                value=Consulting>Consulting</OPTION>
                      </SELECT>
                        <span class="aircraft">Control Click for Multiple Selection</span></TD>

这是PHP代码:

<?php


if(isset($_POST['name'])) {
$to = 'mail.com';
$subject = "Request Form Submission – ".$_POST['company' ];  
$message = '<br>- Name: '.$_POST['name'].'<br>- Title:  '.$_POST['title'].'<br>- Company: '.$_POST['company'].'<br>- Email:  '.$_POST['email'].'<br>- Telephone:  '.$_POST['telephone'].



 $data =  '<br>- Subject of enquiry:  '.$_POST['subject'];



$message .= '<br>- Type of Aircraft: '.$_POST['aircraft'].'<br>- Monthly Utilization: '.$_POST['utilization'].'<br>- Lease Duration: '.$_POST['duration'].'<br>- Route Structure: '.$_POST['route'].'<br>- Comment:  '.nl2br($_POST['comment']).'<br>- Reference: '.$_POST['ref'].'<br>- Region: '.$_POST['region'];

$from = "visitor.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From:" . $from;
if(mail($to,$subject,$message,$headers)) {
    $msg = "Thank you for your request.  Your inquiry has been forwarded to our 

Leasing Department for review.   Should we have any questions or meet your required needs, one of our qualified staff will contact you in regards to your inquiry for further discussion.

Thank you and have a nice day.";

}
?>

我在收件箱中得到的结果是数组而不是这些主题之一:

  • 查询主题:数组

如果您在此代码中看到: name=subject* [] * 删除此[]后有一个数组,我将在选择多个选项后仅得到一个结果。

这是页面提交请求的链接

4

1 回答 1

2

$_POST['subject']是一个数组。你可以使用:

 $data =  '<br>- Subject of enquiry:  '.print_r($_POST['subject'],true);

或者

$data =  '<br>- Subject of enquiry:  '.join(',',$_POST['subject']);
于 2013-03-12T16:08:48.073 回答