我的联系表单没有将下拉值发送到电子邮件

时间:2014-08-07 10:26:35

标签: php html5 forms contact

我的联系表单没有将下拉值发送到电子邮件消息。除了下拉列表外,其他所有内容都会发送。

这是我的表单HTML:

<form id="contactForm" action="#" method="post">

                        <p> For any enquiries enter your contact details and enquiry        below. </p>

                        <fieldset>

                            <div>
                                <input name="name"  id="name" type="text" class="form-poshytip" title="Enter your full name" />
                                <label>Name</label>
                            </div>

                            <div>
                                <input name="email"  id="email" type="text" class="form-poshytip" title="Enter your email address" />
                                <label>Email</label>
                            </div>

                            <div>       
                                <select name="date" id="date" class="form-poshytip" title="Day">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                    <option value="7">7</option>
                                    <option value="8">8</option>
                                    <option value="9">9</option>
                                    <option value="10">10</option>
                                    <option value="11">11</option>
                                    <option value="12">12</option>
                                    <option value="13">13</option>
                                    <option value="14">14</option>
                                    <option value="15">15</option>
                                    <option value="16">16</option>
                                    <option value="17">17</option>
                                    <option value="18">18</option>
                                    <option value="19">19</option>
                                    <option value="20">20</option>
                                    <option value="21">21</option>
                                    <option value="22">22</option>
                                    <option value="23">23</option>
                                    <option value="24">24</option>
                                    <option value="25">25</option>
                                    <option value="26">26</option>
                                    <option value="27">27</option>
                                    <option value="28">28</option>
                                    <option value="29">29</option>
                                    <option value="30">30</option>
                                    <option value="31">30</option>
                                </select> 



                            </div>

                            </br></br>

                            <div>
                                <textarea  placeholder="Your Message" name="comments"  id="comments" rows="5" cols="20" class="form-poshytip" title="Enter your comments"></textarea>
                            </div></br>
                            <label>Select your Hotel</label></br></br>
                            <div>
                                <table>
                                    <tr style="padding-bottom:65px;">
                                        <td>
                                            <input type="radio" id="web" name="web" class="form-poshytip"  value="Le Mauricia" title="Select your hotel">Le Mauricia<br>
                                        </td>
                                        <td style="padding-left:65px;">
                                            <input type="radio" id="web" name="web" class="form-poshytip"  value="Le Canonnier" title="Select your hotel">Le Canonnier<br>
                                        </td>
                                        <td style="padding-left:65px;">
                                            <input type="radio" id="web" name="web" class="form-poshytip"  value="Other" title="Select your hotel">Other<br>
                                        <td>
                                    </tr>

                                    <tr>
                                        <td>
                                            <input type="radio" id="web" name="web" class="form-poshytip" value="Le Victoria" title="Select your hotel">Le Victoria<br>
                                        </td>
                                        <td style="padding-left:65px;">
                                            <input type="radio" id="web" name="web" class="form-poshytip" value="Le Shandrani" title="Select your hotel">Le Shandrani<br>
                                        </td>
                                    </tr>



                                </table>
                            </div>
                            <!-- send mail configuration -->
                            <input type="hidden" value="foo@bar.com" name="to" id="to" />
                            <input type="hidden" value="Enquiry from Website Form" name="subject" id="subject" />
                            <input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
                            <!-- ENDS send mail configuration -->

                            <p><input type="button" value="Send" name="submit" id="submit" /> <span id="error" class="warning">Message</span></p>
                        </fieldset>

                    </form>

这是PHP:

<?php
//vars
$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );

$from = $_POST['email'];

//data
$msg = "NAME: "  .$_POST['name']    ."<br>\n";
$msg .= "EMAIL: "  .$_POST['email']    ."<br>\n";
$msg .= "DATE: "  .$_POST['date']    ."<br>\n";
$msg .= "HOTEL: "  .$_POST['web']    ."<br>\n";
$msg .= "COMMENTS: "  .$_POST['comments']    ."<br>\n";

//Headers
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;


//send for each mail
foreach($to as $mail){
   mail($mail, $subject, $msg, $headers);
}

?>

任何帮助都会非常感激,因为我已经尝试了所有的东西,似乎没有什么能解决它。

0 个答案:

没有答案