PHP将变量从form传递到PHP
PHP pass variables from form to 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(); ?>
当我将表单指向现有的可用性表时,将传递日期。但是当我将可用性表复制到新网站时,它停止传递日期。知道我错过了什么吗?
谢谢!
这可能与'新'站点表上的字段有关。检查以确保它们是正确的数据类型。你正在使用MySQL吗?我的猜测是,您可能没有正确连接到数据库。如果它在本地服务器上工作,但不会将任何数据放入新的服务器表中,那么PHP或Javascript可能没有问题。查看你的数据库
相关文章:
- 将PHP变量传递给jQuery时遇到问题
- 通过javascript重定向html传递php变量
- 如何在php变量中嵌入JQuery代码
- 在javascript函数中使用php变量
- 将地理编码结果转换为php变量以发布到mysql数据库
- 如何在提交表单时将PHP变量传递到Javascript cookie中
- 从Javascript和Php变量创建Html模板文档
- 如何将php变量作为javascript中列表的元素
- 将PHP变量分配给PHP数组
- 如何在没有ajax的情况下将javascript动态数据发送到php变量
- 在Javascript甜甜圈图的PHP变量中引用PHP变量
- 使用javascript访问php变量
- 在Javascript文件中获取PHP变量
- 如何为Javascript数组()的使用准备PHP变量
- 如何获取PHP变量数据并将其存储在JavaScript变量中
- Javascript变量到PHP变量-如果语句不起作用,则发布
- 通过Javascript验证PHP变量
- 如何将Ajax数据值分配给PHP变量
- 如何在 bootsrap 完整日历中使用 PHP 变量
- 在javascript中调用PHP变量