php 数据能够获取 但无法写入数据库 同一文件另一个表可能写入
//session_id(SID);
// session_start();
require_once("../connect/conn_sql.php"); //包含数据库链接文件
if( $_POST["txt_taker"]!="" && $_POST["txt_address"]!="" && $_POST["txt_tel"]!="" && $_POST["txt_paymethod"]!="" ) {
$taker = $_POST["txt_taker"]; //收货人
$address = $_POST["txt_address"]; //收货地址
$tel = $_POST["txt_tel"]; //联系电话
$paymethod = $_POST["txt_paymethod"];//付款方式
$username = $_POST["txt_username"]; //会员名
$pnums = $_POST["txt_pnums"]; //商品数量
$omoney = $_POST["txt_omoney"]; //订单金额
$remark = $_POST["txt_remark"]; //备注
$onum = date('YmdHis').$username; //生成订单号
$createtime = date('Y-m-d H:i:s');; //订单提交日期
$str1 = "insert into tb_order (M_Name,O_Num,P_Nums,O_Money,O_Taker,O_Address,O_Tel,O_Paymethod,O_CreateTime,O_Status,O_Remark)
values('$username','$onum',$pnums,$omoney,'$taker','$address','$tel','$paymethod','$createtime',0,'$remark')";
echo $str1;
$insert1 = mysql_query($str1); //执行SQL语句
echo $insert1; //添加到订单商品详细表
session_start();
$array=explode("@",$_SESSION['producelist']);
$arrayquatity=explode("@",$_SESSION['quatity']);
$s=0;
$i=0;
for($i=0;$i
for($i=0;$i
$sql="select * from tb_product where P_ID =".$pid; $arr = mysql_query($sql); $info=mysql_fetch_array($arr);
$onum = date('YmdHis').$username;
$p_unitprice =$info['P_VPrice'];//单价
$p_nums =$arrayquatity[$i]; //数量
$p_price = $arrayquatity[$i]*$info['P_VPrice']; //小计价格
$str2 = "insert into tb_order_product (O_Num,P_ID,P_UnitPrice,P_Nums,P_Flod,P_Price) values('$onum',$pid,$p_unitprice,$p_nums,1,$p_price)"; $insert2 = mysql_query($str2); //执行SQL语句
}
}
if( $insert1 && $insert2) //如果两张表的数据都插入成功
{
$_SESSION['qk'] = "yes"; //清空购物车
echo "<script>alert('恭喜您,订单提交成功!');window.location.href='../db_zhuyegoujia.php'</script>"; }
else { echo "<script>alert('对不起,订单提交失败!');window.location.href='../db_member_order_add.php'</script>";
}
}
else { echo "<script>alert('请输入带*号的必填信息!');window.location.href='../db_member_order_add.php'</script>";