2014-09-18 2 views
0

양식의 값을 내 세션에 저장하려고합니다. 동일한 페이지를 업데이트 할 때만 작동합니다. 하지만 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']; ?> 

어떻게 수정하여 세션의 저장된 데이터가 다음 페이지에도 전송됩니까? 내 코드가 작동하지만 다른 페이지로 이동하지 않습니다. 다른 페이지로 이동하면 이전에 동일한 페이지에 저장된 값도 이미 값을 변경했지만 동일한 값을 표시합니다.

감사합니다. 네가 나를 도울 수 있기를 바랍니다.

+2

세션을 사용하는 모든 페이지 내에'session_start(); –

+0

게시물을받는 페이지에서 세션 바스를 업데이트 하시겠습니까? – AbraCadaver

+0

답변

1

대화를 통한 대화에 따라 답변을 제출하여 질문을 닫습니다.

첫 번째 파일은 두번째 파일의 상단에

if (isset($_POST['order'])){ 
$_SESSION['carrier'] = $_POST['carrier']; 
$_SESSION['payment'] = $_POST['payment']; 
} 

이동이 있습니다.

관련 문제