多个选择选项表单发送'数组'电子邮件

时间:2017-09-10 18:04:02

标签: php html arrays email contact-form

我遇到了一些问题,我创建的表单必须有多个选项来选择不同的车型,现在问题是我看不到客户选择了什么,因为电子邮件说"车辆制造:阵列"

请帮我在收到的电子邮件中显示他们选择的汽车列表。

编辑:请注意我在代码中使用了noob,需要一些帮助来解决这个问题。我没有编码!

if(isset($_POST{'name'}) && isset($_POST{'email'})&& isset($_POST{'phone'}) )

                                        {$name=$_POST['name'];
                                        $surname=$_POST['surname'];
                                        $phone= $_POST['phone'];
                                        $email= $_POST['email'];
                                        $vehiclemake=$_POST['vehiclemake'];
                                        $vehiclemodel=$_POST['vehiclemodel'];
                                        $yearmodel=$_POST['yearmodel'];
                                        $logo=$_POST['logo'];
                                        $message=$_POST['message'];
                                        if (!empty($name) 
                                        && !empty($email)  
                                        && !empty($phone) 
                                        )
                                        {$to='';
                                        $subject='Contact Us form from cover-worx.co.za website';
                                        $body='Name: ' . $name . "\n\n"
                                        .'Surname: ' .$surname ."\n\n" 
                                        .'Phone number: ' .$phone ."\n\n"
                                        .'Vehicle Make: ' .$vehiclemake ."\n\n"
                                        .'Vehicle Model: ' .$vehiclemodel ."\n\n"
                                        .'Year Model: ' .$yearmodel ."\n\n"
                                        .'Email: ' .$email ."\n\n"
                                        .'Logo Required Yes/No: ' .$logo ."\n\n"
                                        . 'Message:' . $message; 
                                        $headers='From:' .$email;

                                            if ( @mail($to, $subject, $body, $headers)){
                                                echo '<p color="#FF0000">Thanks for contacting us...</p>';} 
                                                else { echo '<p color="#FF0000">Problem with the server, try again later</p>';}}
                                                else{echo '<p color="#FF0000">All fields are required.</p>';}}
                                        ?>



<p class="span4 field"><span class="wpcf7-form-control-wrap your-phone"><select multiple="multiple" name="vehiclemake[]">

                                                        <option value="SelectModel">
                                                            Select Model
                                                        </option>
                                                        <option value="ChevroletCaptiva">
                                                            Chevrolet Captiva
                                                        </option>
                                                        <option value="ChevroletCorsaUtility">
                                                            Chevrolet Corsa Utility
                                                        </option>

这是邮件发送的内容

  

Vehicle Make:Array

     

车辆型号:

     

年份型号:2014

1 个答案:

答案 0 :(得分:0)

您可以使用implode(',', $array)加入数组,以逗号分隔数组值列表。