我正在尝试建立一个简单的PHP联系人,问题是当我从多个列表中选择一个值时,我得到 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 * [] *有一个数组,删除此 [] 我选择多个选项后只会得到一个结果
以下是页面submit request
的链接答案 0 :(得分:2)
$_POST['subject']
是一个数组。你可以使用:
$data = '<br>- Subject of enquiry: '.print_r($_POST['subject'],true);
或
$data = '<br>- Subject of enquiry: '.join(',',$_POST['subject']);