【发布时间】:2014-10-03 02:31:17
【问题描述】:
我的 S_SESSION['carrier'] 和 $_SESSION['payment'] 在我的更新命令后未被识别,我不知道为什么,但在我按下按钮之前,它有效,我尝试回显这些值并且它有效,但在发送命令后,它变得无法识别。
$_SESSION['carrier'] = $_POST['carrier'];
$_SESSION['payment'] = $_POST['payment'];
echo $_SESSION['payment'];
echo $_SESSION['carrier'];
if(isset($_GET['command']) && $_GET['command']=='update'){
$first_name=$_SESSION['first_name'];
$email=$_SESSION['email'];
$home_address=$_SESSION['home_address'];
$mobile_phone=$_SESSION['mobile_phone'];
$carrier=$_SESSION['carrier'];
$payment=$_SESSION['payment'];
$track = "";
$status = "On Process";
$result=mysql_query("insert into customers values('','$first_name','$email','$home_address','$mobile_phone','$carrier','$payment', '$track', '$status')");
echo $payment;
echo $carrier;
$customerid=mysql_insert_id();
date_default_timezone_set("Asia/Hong_Kong");
$date=date('Y-m-d h:i:s');
$result=mysql_query("insert into orders values('','$date','$customerid')");
$orderid=mysql_insert_id();
$qry="SELECT * FROM shipping WHERE ship_name='{$_SESSION['carrier']}'";
$result= @mysql_query($qry);
while ($row=mysql_fetch_assoc($result)){
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$price=get_prod_price($pid); // this one yung mag iinsert ng total sa database.
$huhu=$price+$row['ship_price'];
if($row['ship_price'] > 0){
mysql_query("insert into order_detail values ($orderid,$pid,$q,$huhu)");
}
else{
mysql_query("insert into order_detail values ($orderid,$pid,$q,$price)");
}
}
}
//header('refresh: 0; url=userorder.php'); // to be redirected
exit(); // para mawala ang puta, tumigil ang script.
}
?>
在上面那几行代码中,$_SESSION 不起作用。
但是在这里。
<form name="form1" onsubmit="return validate()">
<input type="checkbox" class="checkbox" id="terms" /> I agree to the <a href="../terms.php" target="_blank"><u><b>terms of service</u></b></a> and adhere to them unconditionally.<br><br>
<input type="hidden" name="command" />
<table border="0" cellpadding="5px" cellspacing="1px" style="font-family:Verdana, Geneva, sans-serif; font-size:11px; background-color:#E1E1E1" width="500px" class="CSSTableGenerator">
<?php
if(is_array($_SESSION['cart'])){
echo '<tr bgcolor="#FFFFFF" style="font-weight:bold"><td></td><td>Name</td><td>Price</td><td>Qty</td><td>Amount</td></tr>';
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$pname=get_product_prod_name($pid);
if($q==0) continue;
?>
<tr bgcolor="#FFFFFF"><td><?php echo $i+1?></td><td><?php echo $pname?></td>
<td>₱<?php echo number_format(get_prod_price($pid),2)?></td>
<td><?php echo $q?></td>
<td>₱<?php echo number_format((get_prod_price($pid)*$q),2)?></td>
</tr>
<?php
}
$qry="SELECT * FROM shipping WHERE ship_name='{$_SESSION['carrier']}'";
$result= @mysql_query($qry);
while ($row=mysql_fetch_assoc($result)){
$tot = get_order_total();
$amounttot = $tot+$row['ship_price'];
?>
<tr><td></td><td colspan="3"><b>Sub Total: </td>
<td>₱<?php echo number_format($tot,2); ?></b></td></tr>
<tr><td></td><td colspan='3'><b>
<?php
if($row['ship_price']>0){
echo "Shipment Option: ".$_SESSION['carrier']."<td>₱ ".$row['ship_price']."</td>";
echo "<tr><td></td><td colspan='3'><b>Order Total: </td>
<td><b>₱";
echo number_format($amounttot,2);
echo "</b></td></tr>";
}
else{
echo "Shipment Option: ".$_SESSION['carrier']."<td>₱ ".$row['ship_price']."</td>";
echo "<tr><td></td><td colspan='3'><b>Order Total: </td>
<td><b>₱";
echo number_format($amounttot,2);
echo "</b></td></tr>";
}
}
?></b></td></tr>
<tr><td colspan="5"><div align="right">
<input type="button" value="View Shopping Cart" onclick="window.location='shoppingcart.php'">
<input type="button" value="Change Shipping Options" onclick="window.location='shipping.php'">
<input type="submit" disabled="disable" value="Place Order" id="submitBtn"/></td></tr>
<?php
}
?>
</table>
<!--<table>
<tr><td><input type="button" value="View Shopping Cart" onclick="window.location='shoppingcart.php?'"><input type="button" value="Change Shipping Options" onclick="window.location='shipping.php?'"><input type="submit" value="Place Order"/></td></tr>
</table> -->
</form>
在这个上运行良好,我不知道出了什么问题,请帮忙。谢谢。
【问题讨论】: