Selepas pengguna menambah item ke troli beli-belah dan menyimpannya ke sesi, bagaimana untuk menyimpan maklumat troli beli-belah dalam pangkalan data?
cyjy622
cyjy622 2019-11-17 16:03:36
0
0
999

<?php
header("Content-type: text/html; charset=utf-8");
session_start();//Start session
// session_destroy();
// die();
/ / var_dump($_SESSION);
// die();
if(isset($_SESSION['username']) &&!empty($_SESSION['username'])){

}
else{
echo ' <script language="JavaScript">;
          alert("Belum log masuk, sila log masuk dahulu!!");</script>';
                      echo "<.script>=';header.h php'< ;/script>"; keluar;
}

// $uid = $_SESSION['uid'];
$goods_id = $_POST['goods_id'];//Dapatkan id produk
// $ saiz = $_POST ['saiz'];
// $warna = $_POST['warna'];
$nombor = $_POST['bilangan'];//Dapatkan kuantiti produk // $numcol="$size "."$color "; // var_dump($_POST);
// die();


if(kosong($_SESSION["gwc"])) { //1. Troli beli-belah kosong, klik untuk menambah beli-belah buat kali pertama Kereta          $arr[$goods_id] =array(
            'goods_id'                          
      );     "                                                                                                                              r( $arr);
                                                                                                                                                                                                                         = palsu; sama ada produk berada dalam troli beli-belah, KEY ialah id produk
foreach($arr as $k=> $v)
{

if($k==$goods_id)
{                 $chuxian = benar ;                         } lain{
                                                                                                                                 } $
$ _SESSION ["gwc"] = $ arr;
}
lain
{// 2. Jika tiada produk dalam troli beli-belah
$ ARR [$ goods_id] = array (
'goods_id' = & gt; $ goods_id ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      JavaScript">;
alert("Tambahan berjaya!");location.href="header.php";</script>;';
                             keluar; ;

cyjy622
cyjy622

membalas semua(0)
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan