Reputation: 131
I'm trying to set up a simple PHP contact, the issue is when I choose a value from Multiple List I get the ARRAY . result in the email inbox instead of the values like: Subject of enquiry: 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>
Here is the PHP Code:
<?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.";
}
?>
What result I am getting in the inbox is array instead of one of those subject:
If you see in this code: name=subject*[]* there is a array by removing this [] I will get only one result after choosing multiple option.
Here is the link of the page submit request
Upvotes: 0
Views: 1477
Reputation: 5428
$_POST['subject']
is an array. You could use:
$data = '<br>- Subject of enquiry: '.print_r($_POST['subject'],true);
or
$data = '<br>- Subject of enquiry: '.join(',',$_POST['subject']);
Upvotes: 2