我更像是一名前端开发人员,所以后端的东西有时会让我感到困惑。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
感谢您的回答!你能指点我一个新手指南来执行该命令吗? –