我正在尝试将表单中的值存储到我的会话中,它仅在我更新同一页面时才有效。但是当我尝试在表单中输入onclick =“window.location ='billing.php'”或action =“billing.php”时。 它不会更新会话中存储的值。
这是我的代码。
<form method="post" name="order">
<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='center'>
<tr>
<td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="LBC") echo "checked";?> value="LBC"></td>
<td><img src="../paymentoptions/LBC.jpg" alt="LBC" class="picture"/></td>
<td><p>The Shipping takes 1-2 days for NCR and 2-3 days for any provincial.<p>
<div id='price'> Additional ₱250 </div></td>
</tr>
<tr>
<td><input type="radio" name="carrier" <?php if (isset($carrier) && $carrier=="PickUp") echo "checked";?> value="PickUp"></td>
<td><img src="../paymentoptions/Pick-up.jpg" alt="Pick-Up" class="picture"/></td>
<td><p>Office hours: 10:00 am to 5:00 pm<p>
<div id='price'> Free!! </div></td>
</tr>
</table>
<br>
<br>
<center><h1>Payment Method</h1></center>
<table width="900" border="0" align="center" cellpadding="2" cellspacing="0" id='centerdown'>
<tr>
<td><input type="radio" name="payment" <?php if (isset($payment) && $payment=="BPI") echo "checked";?> value="BPI"></td>
<td><img src="../paymentoptions/BPI.jpg"></td>
<td><p>Pay by BPI bank deposit (we need confirmation of payment through email.)<p></td>
</tr>
<tr>
<td><input type="radio" name="payment" <?php if (isset($payment) && $payment=="PickUp") echo "checked";?> value="PickUp"></td>
<td><img src="../paymentoptions/Pick-up.jpg"></td>
<td><p>Pick up. You have 5 days reservation period. You pay for the merchandise upon pick-up<p></td>
</tr>
</table>
<table>
<tr><td><input type="button" value="View Shopping Cart" onclick="window.location='shoppingcart.php?'"></td><td><input type="submit" name="order" value="Place Order"><!--<input type="button" value="Confirm Order" onclick="window.location='quotation.php?'">--></td></tr>
</table>
</form>
<?php
if (isset($_POST['order'])){
$_SESSION['carrier'] = $_POST['carrier'];
$_SESSION['payment'] = $_POST['payment'];
}
?>
</div>
<?php echo $_SESSION['carrier']; ?>
<?php echo $_SESSION['payment']; ?>
如何修复它,以便会话中存储的数据也将在下一页中传输?我的代码现在可以使用,但不会转到另一个页面。当我转到另一个页面时,先前存储在同一页面中的值也会显示相同的值,即使我已经更改了该值。
谢谢你。希望你能帮助我。答案 0 :(得分:1)
根据我们通过聊天进行的对话,我将提交作为回答问题的答案。
您的第一个文件有
if (isset($_POST['order'])){
$_SESSION['carrier'] = $_POST['carrier'];
$_SESSION['payment'] = $_POST['payment'];
}
将其移至第二个文件的顶部。