เอ่อ...จะสร้าง addcart แบบไม่ต้องสมัครสมาชิกจะทำอย่างไรคะ เพราะถ้า set ค่า user ให้มันจะสร้าง user เยอะมาก แล้วก็ถ้าเข้าพร้อมกันหลายเครื่อง มันจะเป็น cart เดียวกันอ่ะค่ะ
Code (PHP)
<?include('cdate.php');
include("system/include/class_main.inc");
include("system/include/functionWeb.php");
session_start();
if(trim($_SESSION['id_member']) == "")
{ $db3 = new admin_control();
$sql = "select * from tb_member ";
$db3->send_cmd($sql);
$norder = $db3->num_rows();
if($norder==0)
$norder = 1;
if($norder<=30)
$norder = 31;
else
$norder = $norder+1;
$id_member = $norder;
$db4 = new admin_control();
$sql = "insert into tb_membe r(id_member,namesur,addr) values('$id_member','General','NoAddress') ";
$db4->send_cmd($sql);
$_SESSION['id_member'] = $id_member;
echo "<meta http-equiv=\"refresh\" content=\"0; \">";
}
else
{
include('cdate.php');
include("system/include/class_main.inc");
include("system/include/functionWeb.php");
$db1 = new admin_control();
$id_pro = trim($_GET['id_pro']);
$id_type = trim($_GET['id_type']);
$size_pro = trim($_GET['size_pro']);
$color_pro = trim($_GET['color_pro']);
$qty = trim($_GET['qty']);
if(($_GET['flag']=="del") && (trim($_GET['id_pro'])!=""))
{
$sql = "delete from tb_cart where id_pro = '$id_pro' and id_member='$_SESSION[id_member]'";
$db1->send_cmd($sql);
}
if(isset($_POST['SubmitCal']))
{
$proid = $_POST['proid'];
$qty = $_POST['qty'];
for($i=0;$i<count($proid);$i++)
{
$tmp = $qty[$i];
$tmp1 = $proid[$i];
$sql = "update tb_cart set
qtyc = $tmp where
id_member = '$_SESSION[id_member]'and id_pro = '$tmp1' ";
$db1->send_cmd($sql);
}
}
if((trim($_GET['id_pro'])!="") && (trim($_GET['id_type'])!="") && (trim($_GET['qty'])!=""))
{
$sql = "select * from tb_cart where id_member = '$_SESSION[id_member]' and id_pro='$id_pro' and size_pro = '$size_pro' and color_pro='$color_pro' ";
$db1->send_cmd($sql);
if($db1->num_rows() > 0)
{
$sql = "update tb_cart set qtyc = qtyc + $qty
where id_member = '$_SESSION[id_member]'
and id_pro = '$id_pro' and size_pro='$size_pro'
and color_pro='$color_pro' ";
$db1->send_cmd($sql);
}
else
{
$dbc = new admin_control();
$sqlc = "select * from tb_product where id_pro = '$id_pro'";
$dbc->send_cmd($sqlc);
$rsc = $dbc->fetch_data();
$deli = $rsc['deli_pro'];
$sql = "insert into tb_cart(id_member,id_pro,qtyc,size_pro,deli_pro,color_pro) values('$_SESSION[id_member]','$id_pro','$qty','$size_pro','$deli','$color_pro')";
$db1->send_cmd($sql);
}
}
?>..................................