0

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:

  • Subject of enquiry: Array

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

1 Answer 1

2

$_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']);
Sign up to request clarification or add additional context in comments.

3 Comments

In the first Case I got : Subject of enquiry: Array ( [0] => ACMI / Wet Lease [1] => Dry Lease [2] => Charter Services )
Isn't that what you want? If not, what do you want?
In the case of second : - Subject of enquiry: Dry Lease,Charter Services,Religious Pilgrimage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.