<?php
session_start();
include_once("config.php");
include_once("conn.php");
$ddnumber=substr(date("YmdHis"),2,8).mt_rand(100000,999999);
$yprice="500";
$array=explode("@",$_SESSION["goodsid"]);
$arraynum=explode("@",$_SESSION["goodsnum"]);
$totalprice=0;
 for($i=0;$i<count($array);$i++){
	if($array[$i]!=""){
	 $sqlcart=mysql_query("select * from tb_commodity where tb_commodity_id='".$array[$i]."'",$conn);
	 $infocart=mysql_fetch_array($sqlcart);
     
	 $totalprice+=$infocart["tb_commodity_price"]*$arraynum["$i"];
	}
}
$totalprice=$totalprice+$yprice;

if(mysql_query("insert into tb_commodity_order_form(ddnumber,recuser,address,yb,qq,email,mtel,gtel,shfs,spc,slc,yprice,totalprice,createtime) values('".$ddnumber."','".$_POST["recuser"]."','".$_POST["address"]."','".$_POST["yb"]."','".$_POST["qq"]."','".$_POST["email"]."','".$_POST["mtel"]."','".$_POST["gtel"]."','".$shfs."','".$_SESSION["goodsid"]."','".$_SESSION["goodsnum"]."','".$yprice."','".$totalprice."','".date("Y-m-d H:i:s")."')",$conn)){
session_unregister("goodsid");
session_unregister("goodsnum");
echo "<script>window.location.href='shopping_dd.php?ddno=".base64_encode($ddnumber)."';</script>";
}else{

echo "<script>alert('订单信息保存失败，请重试！');</script>";

}
$smarty->display("shopping_dd.tpl");
?>

