PHP将变量从表单传递给php

时间:2015-08-27 16:51:02

标签: javascript php jquery wordpress forms

我更像是一名前端开发人员,所以后端的东西有时会让我感到困惑。

我复制了现有网站上的一些代码,但它在新网站上没有按预期运行。

我正在使用酒店预订小部件。主页上有一个表格用于输入入住和退房日期。单击提交按钮后,表单将链接到所有可用房间的可用性表。

在当前网站上,表格上输入的日期将传递到可用性表。但是,当我复制代码时,它不再起作用。我错过了什么?

以下是表单代码:

<script type="text/javascript">

jQuery(document).ready(function() {
    jQuery('.MyDate1').datepicker({
        dateFormat : 'dd/mm/yy'
    });

jQuery(document).ready(function() {
    jQuery('.MyDate2').datepicker({
        dateFormat : 'dd/mm/yy'
 minDate:  0,
onSelect: function(date){
var date2 = $('.MyDate2').datepicker('getDate');
            date2.setDate(date2.getDate()+1);
            $('.MyDate1').datepicker('setDate', date2);
    });

</script>

<?php 
// ==================================================
// Displays the Booking Panel Date selection options.
// ==================================================

// Set up some default Check-in/Check-out Dates.
$checkinToday = date('d/m/Y');
$checkoutTomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('Y'));
$checkoutTomorrow = date('d/m/Y', $checkoutTomorrow);
?>
              <form name="bookingform" action="https://www.clarionsuitesgateway.com.au/clarionhotel/booking-system/" method="post">
              <div class="booking-h3">Check Availability</div>
              <div class="booking-row">
                <div class="booking-label">Check In Date</div>
                <div class="booking-field"><input name="frmCheckin" id="frmCheckin" type="text" class="MyDate1" value="<?php echo $checkinToday; ?>" style="width:100%" /></div>
              </div>
              <div class="booking-row">
                <div class="booking-label">Check Out Date</div>
                <div class="booking-field"><input name="frmCheckout" id="frmCheckout" type="text" class="MyDate2" value="<?php echo $checkoutTomorrow; ?>" style="width:100%" /></div>
              </div>
              <div class="booking-row">
                <div class="booking-row-box">
                  <div class="booking-label">Adults</div>
                  <div class="booking-field">
                      <select id="frmAdults" name="frmAdults">
                        <?php for ($i = 1; $i <= 10; $i++): ?>
                                  <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php endfor; ?>
                      </select>            
                  </div>
                </div>
                <div class="booking-row-box">
                  <div class="booking-label">Children</div>
                  <div class="booking-field">
                      <select id="frmChildren" name="frmChildren">
                        <?php for ($i = 0; $i <= 10; $i++): ?>
                                  <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                        <?php endfor; ?>
                      </select>            
                  </div>
                </div>
                <br clear="all">
              </div>
              <div class="booking-row">
                <div class="booking-button">
                  <input type="submit" value="Check Availability" name="Send" alt="Check Availability" />
                  <input type="hidden" name="Submit" />
                </div>
              </div>              
              </form>

以下是它指向的可用性表:

<?php
// ==================================================
// BOOKING BUTTON specific page.
// ==================================================
// Set some default dates incase nothing is selected (we're not doing any error checking for this).
// Today
$CheckinDay = date('d');
$CheckinMonth = date('m');
$CheckinYear = date('Y');
// Tomorrow
$CurrentDate = date('Y/m/d');
$Tomorrow = strtotime('+1 day', strtotime($CurrentDate)) ;
$Tomorrow = date('d/m/Y', $Tomorrow);
$arrCheckoutDate = explode("/", $Tomorrow);
$CheckoutDay = $arrCheckoutDate[0];
$CheckoutMonth = date("M", mktime(0, 0, 0, $arrCheckoutDate[1], 1, 2012));
$CheckoutYear = $arrCheckoutDate[2];

$NumberAdults = 1;
$NumberChildren = 0;

if ( isset($_POST["Submit"]) ) 
{
    if ( strlen($_POST['frmCheckin']) )
    {
        $arrCheckinDate = explode("/", $_POST['frmCheckin']);
        $CheckinDay = $arrCheckinDate[0];
        $CheckinMonth = date("M", mktime(0, 0, 0, $arrCheckinDate[1], 1, 2012));
        $CheckinYear = $arrCheckinDate[2];
    }
    if ( strlen($_POST['frmCheckout']) )
    {
        $arrCheckoutDate = explode("/", $_POST['frmCheckout']);
        $CheckoutDay = $arrCheckoutDate[0];
        $CheckoutMonth = date("M", mktime(0, 0, 0, $arrCheckoutDate[1], 1, 2012));
        $CheckoutYear = $arrCheckoutDate[2];
    }
    $NumberAdults = $_POST['frmAdults'];
    $NumberChildren = $_POST['frmChildren'];
}
?>
<?php get_header(); ?>
<div id="ContentOuterContainer">
  <div id="ContentInnerContainerBookings">
       <?php while ( have_posts() ) : the_post(); ?>

                 <iframe src="https://www.thebookingbutton.com.au/xxx/properties/xxx?utf8=%E2%9C%93&locale=en&check_in_date=<?php echo $CheckinDay;?>+<?php echo $CheckinMonth;?>+<?php echo $CheckinYear;?>&check_out_date=<?php echo $CheckoutDay;?>+<?php echo $CheckoutMonth;?>+<?php echo $CheckoutYear;?>&number_adults=<?php echo $NumberAdults; ?>&number_children=<?php echo $NumberChildren; ?>&commit=Check+Availability" height="590" width="1047" frameborder="0" scrolling="yes" allowtransparency="true"></iframe>


       <?php endwhile; ?>
    <div class="clear"></div>
  </div>
</div>
<div class="gap"></div>
<?php get_footer(); ?>

当我将表单定向到现有可用性表时,会传递日期。但是当我将可用性表复制到新网站时,它会停止传递日期。知道我错过了什么吗?

谢谢!

0 个答案:

没有答案