我更像是一名前端開發人員,所以後端的東西有時會讓我感到困惑。PHP從表單到php傳遞變量
我已經複製了現有網站的一些代碼,但它在新網站上沒有按預期運行。
我在使用酒店預訂小部件。主頁上有一個用於輸入入住和退房日期的表格。點擊提交按鈕後,表單鏈接到所有可用房間的可用性表。
在當前網站上,表單上輸入的日期被傳遞給可用性表。但是,當我複製代碼時,它不再像那樣起作用。我錯過了什麼?
這裏是表單代碼:
<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(); ?>
當我直接的形式向現有的可用性表,日期被通過。但是,當我將可用性表複製到新網站時,它會停止通過日期。任何想法我失蹤?
謝謝!
因此,如果您在可用性表頁上輸入'print_r($ _ POST);'是否爲空? – Rasclatt
感謝您的回答!你能指點我一個新手指南來執行該命令嗎? –