酒店预订日期选择器

时间:2014-05-11 02:26:48

标签: php

我目前正在酒店网站上工作,该网站需要根据用户的到达和离开日期选择来选择预订。我遇到了让PHP运行并重定向到包含下拉选择器值的URL的问题。

到目前为止,我有HTML:

<span name="checkIn">
            <tr>      
                <td>
                    <span class="formtext">
                        <strong>Check-In:</strong>
                    </span>
                </td>
                <td>
                    <span class="custom-dropdown custom-dropdown--white custom-dropdown--small">
                        <select name="checkInMonth" class="custom-dropdown__select custom-dropdown__select--white">
                            <option value="01">January</option>
                            <option value="02">February</option>
                            <option value="03">March</option>
                            <option value="04">April</option>
                            <option value="05" selected="selected">May</option>
                            <option value="06">June</option>
                            <option value="07">July</option>
                            <option value="08">August</option>
                            <option value="09">September</option>
                            <option value="10">October</option>
                            <option value="11">November</option>
                            <option value="12">December</option>
                        </select>
                    </span>
                </td>
                <td>
                    <span class="custom-dropdown custom-dropdown--white custom-dropdown--small">
                        <select name="checkInDate" class="custom-dropdown__select custom-dropdown__select--white">
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11" selected="selected">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">31</option>
                        </select>
                    </span>
                    </td>
                    <td>
                        <span class="custom-dropdown custom-dropdown--white custom-dropdown--small">
                            <select name="checkInYear" class="custom-dropdown__select custom-dropdown__select--white">
                                <option value="2014">2014</option>
                                <option value="2015">2015</option>
                                <option value="2016">2016</option>
                                <option value="2016">2017</option>
                                <option value="2016">2018</option>
                                <option value="2016">2019</option>
                                <option value="2016">2020</option>
                                <option value="2016">2021</option>
                                <option value="2016">2022</option>
                                <option value="2016">2023</option>
                                <option value="2016">2024</option>
                                <option value="2016">2025</option>
                                <option value="2016">2026</option>
                                <option value="2016">2027</option>
                                <option value="2016">2028</option>
                                <option value="2016">2029</option>
                                <option value="2016">2030</option>
                                <option value="2016">2031</option>
                                <option value="2016">2032</option>
                                <option value="2016">2033</option>
                                <option value="2016">2034</option>
                                <option value="2016">2035</option>
                            </select>
                        </span>
                    </td>
                </tr>
            </span>
            <tr>
                <td>
                    <a href="#" onclick="bookengine.php" class="bookButton">Book Now</a>
                </td>
            </tr>

和PHP:

<?php
$checkInMonth = $_POST['checkInMonth'];
$checkInDate = $_POST['checkInDate'];
$checkInYear = $_POST['checkInYear'];
$checkOutMonth = $_POST['checkOutMonth'];
$checkOutDate = $_POST['checkOutDate'];
$checkOutYear = $_POST['checkOutYear'];
header("Location: http://book.[REDACTED].com/[REDACTED]/selectRoom.do?propertyCode=XXXXX&arrivalDay=$checkInDate&arrivalMonthYear=$checkInYear$checkInMonth&departureDay=$checkOutDate&departureMonthYear=$checkOutYear$checkOutMonth");
?>

我做错了什么?

1 个答案:

答案 0 :(得分:1)

根据您粘贴的代码,您似乎没有使用表单。因此,当您点击&#34;现在预订&#34;链接没有数据传递到您的PHP页面。考虑将这些元素包装在表单中,将操作设置为bookengine.php,并使用正确的提交按钮。