|
<?php $cart->deliverfee = 0; //請設定購物車的運費 ?><?php //加入購物車Class的宣告 require_once('cart/EDcart.php'); session_start(); $cart =& $_SESSION['edCart']; if(!is_object($cart)) $cart = new edCart(); ?> <?php $cart->deliverfee = 150; //請設定購物車的運費 ?> <?php virtual('/Connections/minaSQL.php');?><?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; }
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }
$editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO orders (SubTotal, Shipping, GrandTotal, CustomerName, CustomerEmail, CustomerAddress, CustomerPhone, paytype) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['SubTotal'], "int"), GetSQLValueString($_POST['Shipping'], "int"), GetSQLValueString($_POST['GrandTotal'], "int"), GetSQLValueString($_POST['CustomerName'], "text"), GetSQLValueString($_POST['CustomerEmail'], "text"), GetSQLValueString($_POST['CustomerAddress'], "text"), GetSQLValueString($_POST['CustomerPhone'], "text"), GetSQLValueString($_POST['paytype'], "text"));
mysql_select_db($database_minaSQL, $minaSQL); $Result1 = mysql_query($insertSQL, $minaSQL) or die(mysql_error()); //取得最新的訂單編號 $max_id = mysql_insert_id(); $_SESSION['OrderID'] = $max_id; //將編號存入Session值中
//將購物車的詳細內容一筆筆寫入資料表 if($cart->itemcount > 0) { foreach($cart->get_contents() as $item) { $insertSQL = sprintf("INSERT INTO orderdetail (OrderID, ProductID, ProductName, UnitPrice, Quantity) VALUES (%s, %s, %s, %s, %s)", GetSQLValueString($max_id, "int"), GetSQLValueString($item['id'], "int"), GetSQLValueString($item['info'], "text"), GetSQLValueString($item['price'], "int"), GetSQLValueString($item['qty'], "int")); mysql_select_db($database_minaSQL, $minaSQL); $Result1 = mysql_query($insertSQL, $minaSQL) or die(mysql_error()); } } $insertGoTo = "/shopok.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; }header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_minaSQL, $minaSQL); $query_Recproduct = "SELECT * FROM orders"; $Recproduct = mysql_query($query_Recproduct, $minaSQL) or die(mysql_error()); $row_Recproduct = mysql_fetch_assoc($Recproduct); $totalRows_Recproduct = mysql_num_rows($Recproduct); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> 因為小弟是超初學者,所以都是上網和看書學的,只要我插入資料後沒有設定轉頁就不會跳出錯誤訊息,資料是都有順利存入我要的空間,但是就是不讓我轉到下一頁,我是和智邦科技租的伺服器空間,不知道有沒有差,我被這問題卡一個禮拜了,官網一直不能推出,壓力超大,麻煩請一定要幫幫小弟 |