PHP data can be obtained but cannot be written to the same file as the database another table may write
Last Update:2016-06-13
Source: Internet
Author: User
PHP data can be obtained but cannot be written to the same file as the database another table may write
session_id (SID);
Session_Start ();
Require_once (".. /connect/conn_sql.php "); Include database link file
if ($_post["Txt_taker"]!= "" && $_post["txt_address"]!= "" && $_post["Txt_tel"]!= "" && $_post[" Txt_paymethod "]!=" ") {
$taker = $_post["Txt_taker"]; Consignee
$address = $_post["txt_address"]; Shipping Address
$tel = $_post["Txt_tel"]; Contact phone
$paymethod = $_post["Txt_paymethod"];//payment method
$username = $_post["Txt_username"]; Member name
$pnums = $_post["Txt_pnums"]; Number of goods
$omoney = $_post["Txt_omoney"]; Order Amount
$remark = $_post["Txt_remark"]; Note
$onum = Date (' Ymdhis '). $username; Generate Order Number
$createtime = Date (' y-m-d h:i:s ');; Order Submission Date
$str 1 = "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 $str 1;
$insert 1 = mysql_query ($str 1); Execute SQL statement
echo $insert 1; Add to order Product detail table
Session_Start ();
$array =explode ("@", $_session[' producelist ');
$arrayquatity =explode ("@", $_session[' quatity ');
$s = 0;
$i = 0;
for ($i =0; $i
if ($s!=0) {
for ($i =0; $i
$pid = $array [$i]; Product number
$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 '];//unit price
$p _nums = $arrayquatity [$i]; Number
$p _price = $arrayquatity [$i]* $info [' P_vprice ']; Subtotal Price
$str 2 = "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) "; $insert 2 = mysql_query ($str 2); Execute SQL statement
}
}
if ($insert 1 && $insert 2)//If data for both tables is inserted successfully
{
$_session[' qk '] = "yes"; Empty shopping Cart
echo "";}
else {echo "";
}
}
else {echo "";