Reputation: 191
I am trying to store a value from a form into my session, It works ONLY when i update the same page. but when i try to put onclick="window.location='billing.php'" or action="billing.php" in the form. it does not update the value stored in the session.
here are my codes.
<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']; ?>
how do i fix it so the stored data in the session will also be transfered in the next page? my code right now works but does not go to another page. when i go to another page, the value previously stored in the same page also shows the same value even though i changed the value already.
thank you. hope you can help me.
Upvotes: 0
Views: 59
Reputation: 74217
As per our conversation via chat, am submitting as the answer to close the question.
Your first file has
if (isset($_POST['order'])){
$_SESSION['carrier'] = $_POST['carrier'];
$_SESSION['payment'] = $_POST['payment'];
}
move that to the top of your 2nd file.
Upvotes: 1