Php 发布隐藏值
嘿,那里, 我有三页: (1) bookingfacilities.php (2) booking_now.php (3) successfulbooking.php 它们是联系在一起的 我想使用隐藏字段/值将数据从bookingfacilities.php传递到successfulbooking.php。但是,我的数据没有在successfulbooking.php中打印出来 这是我的密码:Php 发布隐藏值,php,forms,hidden,Php,Forms,Hidden,嘿,那里, 我有三页: (1) bookingfacilities.php (2) booking_now.php (3) successfulbooking.php 它们是联系在一起的 我想使用隐藏字段/值将数据从bookingfacilities.php传递到successfulbooking.php。但是,我的数据没有在successfulbooking.php中打印出来 这是我的密码: 从“booking_now.php”开始: $date=“$day-$month-$year” 来自
- 从“booking_now.php”开始:
$date=“$day-$month-$year”代码>
- 来自“successfulbooking.php”;
如果来自POST请求,则必须使用
而不是$\u POST['date']
(如果是GET请求,则使用$\u GET)。决不能假设启用了$date
我不确定你刚才在那里做了什么,但从我可以看出这就是你想要的: bookingfacilities.php注册全局变量。即使是这样,它也被弃用了,您永远不应该以这种方式使用它 直接参考
或$\u POST
变量。您的表单很可能正在发布,因此您希望您的代码看起来像这样:$\u GET
";<input type="hidden" name="date" id="hiddenField" value="<?php echo $_POST['date'] ?>" />
<?php $date = $_POST['date']; // add code here ?>
session_start(); $date = $_SESSION['form_date'];
我也不知道你想用第三个页面(booking_now.php)做什么。可能会晚一点到派对,但为什么不使用会话来存储数据呢 bookingfacilities.php<?php $date = $_POST['date']; // add code here ?>
successfulbooking.phpsession_start(); $date = $_SESSION['form_date'];
session_start(); $_SESSION['form_date'] = $date;
没有人会看到这一点。在第一页-booking facilities.php,是否正确,我还需要添加一个隐藏字段函数?!事实上,这是一个好主意。当您可以简单地使用会话时,没有理由使用Get和Post数据。这是最好的解决方案。当我需要数据在多个页面中持久化时,我使用会话变量。如果不是,则你必须在每一页上输入一次又一次地发布数据。此外,使用的变量是“booking_now”…如果是现在,为什么不使用PHP的date()方法。如:$today=date(“m-d-Y”);