Php 命令后的未识别索引
我的S_会话['carrier']和$_会话['payment']在我的更新命令后没有被识别,我不知道为什么,但在我按下按钮之前,它工作了,我尝试了回显值,它工作了,但在发送命令后,它就被识别了Php 命令后的未识别索引,php,forms,session,post,Php,Forms,Session,Post,我的S_会话['carrier']和$_会话['payment']在我的更新命令后没有被识别,我不知道为什么,但在我按下按钮之前,它工作了,我尝试了回显值,它工作了,但在发送命令后,它就被识别了 $_SESSION['carrier'] = $_POST['carrier']; $_SESSION['payment'] = $_POST['payment']; echo $_SESSION['payment']; echo $_SESSION['carrier'];
$_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.
}
?>
$\u SESSION['carrier']=$\u POST['carrier'];
$_SESSION['payment']=$_POST['payment'];
echo$_会话[‘付款’];
echo$_会话['carrier'];
如果(isset($\u GET['command'])&&&$\u GET['command']=='update'){
$first\U name=$\U会话['first\U name'];
$email=$_会话['email'];
$home\u address=$\u会话['home\u address'];
$mobile_phone=$_会话['mobile_phone'];
$carrier=$\会话['carrier'];
$payment=$\会话['payment'];
$track=“”;
$status=“On Process”;
$result=mysql_查询(“插入到客户值中(“$first_name”、“$email”、“$home_address”、“$mobile_phone”、“$carrier”、“$payment”、“$track”、“$status”);
回音$付款;
echo$carrier;
$customerid=mysql\u insert\u id();
日期默认时区设置(“亚洲/香港”);
$date=日期('Y-m-d h:i:s');
$result=mysql_查询(“插入到订单值('''$date','$customerid'));
$orderid=mysql_insert_id();
$qry=“从发货中选择*,其中发货名称=“{$\u会话['carrier']}”;
$result=@mysql\u查询($qry);
而($row=mysql\u fetch\u assoc($result)){
$max=计数($_会话['cart']);
对于($i=0;$i 0){
mysql_查询(“插入订单_详细值($orderid,$pid,$q,$huhu)”);
}
否则{
mysql_查询(“插入订单_详细值($orderid,$pid,$q,$price)”);
}
}
}
//标题('refresh:0;url=userorder.php');//重定向
退出();//帕拉·马瓦拉和普塔,图米吉尔和剧本。
}
?>
在上面的代码行中,$\u会话无法工作
但是在这里
<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>
我同意并无条件遵守这些条款。
₱
₱
小计:
₱
您的输入中没有名为command:的值,请重试
<input type="hidden" name="command" value="update"/>
尝试使用isset
,它将捕获您未识别的索引错误
if (isset($_POST['FORM NAME ON PREVIOUS PAGE'])){
$_SESSION['carrier'] = $_POST['carrier'];
$_SESSION['payment'] = $_POST['payment'];
}
希望它能起作用。我能。我有这个剧本<代码>函数validate(){var f=document.form1;f.command.value='update';f.submit();alert(“Order submitted”);}
哦,情况并非如此。服务器传递的错误是什么?打印($\u会话)
,然后验证是否设置了付款和承运商。