コード例 #1
0
ファイル: route.php プロジェクト: ngogiangthanh/avalon-web
     PostList((int) $_POST["items"], (int) $_POST["currentPage"], (int) $_POST["categoryID"]);
     break;
     //xu ly lay mot san pham trong csdl
 //xu ly lay mot san pham trong csdl
 case 'element':
     GetElement((int) $_GET["id"]);
     break;
     //xu ly them san pham vao gio hang
 //xu ly them san pham vao gio hang
 case 'addcart':
     AddItem((int) $_POST['id'], $_POST['name_pro'], $_POST['name_cat'], $_POST['img'], $_POST['price_vnd'], $_POST['price_usd'], $_POST['price_off'], $_POST['amount'], $_POST['unit_name']);
     break;
     //xu ly yeu cau cap nhat so luong trong gio hang
 //xu ly yeu cau cap nhat so luong trong gio hang
 case 'updateitemcart':
     UpdateItem((int) $_GET['id'], (int) $_GET['amount']);
     echo "true";
     break;
     //xu ly yeu cau xoa bo mot san pham trong gio hang
 //xu ly yeu cau xoa bo mot san pham trong gio hang
 case 'removeitemcart':
     DeleteItem((int) $_GET['id']);
     echo "true";
     break;
     //xu ly yeu cau xoa bo mot san pham trong gio hang
 //xu ly yeu cau xoa bo mot san pham trong gio hang
 case 'sendcart':
     if ($_SESSION['security_code'] == $_GET['captcha']) {
         SendCart();
         echo "true";
     } else {
コード例 #2
0
ファイル: list.php プロジェクト: stevenc49/dotcsc
        return $_COOKIE["bookListId"];
    } else {
        // There is no cookie set. We will set the cookie
        // and return the value of the users session ID
        session_start();
        setcookie("bookListId", session_id(), time() + 3600 * 24 * 30);
        return session_id();
    }
}
switch ($_GET["action"]) {
    case "add_item":
        AddItem($_GET["id"], $_GET["con"]);
        ShowCart();
        break;
    case "update_item":
        UpdateItem($_GET["id"], $_GET["con"]);
        ShowCart();
        break;
    case "remove_item":
        RemoveItem($_GET["id"]);
        ShowCart();
        break;
    case "remove_all":
        RemoveAll();
        ShowCart();
        break;
    default:
        ShowCart();
}
function AddItem($bookId, $container)
{
コード例 #3
0
ファイル: cart.php プロジェクト: stevenc49/dotcsc
function AddItem($itemId, $qty)
{
    //This create an error
    //function can not detect connection
    $dbUser = "******";
    $dbPass = "";
    $dbName = "cart";
    $dbServer = "127.0.0.1";
    // Connect to the database and return
    // true/false depending on whether or
    // not a connection could be made.
    $s = mysql_connect($dbServer, $dbUser, $dbPass);
    $d = mysql_select_db($dbName, $s);
    //tests if connection is a sucess
    if ($d) {
        print "in";
        //connection success
    } else {
        print "Not In";
        //connection fail
    }
    $result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = {$itemId}");
    $row = mysql_fetch_row($result);
    $numRows = $row[0];
    //tests if connection is a sucess
    if ($d) {
        print "in";
        //connection success
    } else {
        print "Not In";
        //connection fail
    }
    if ($numRows == 0) {
        // This item doesn't exist in the users cart,
        // we will add it with an insert query
        //This also creates an error
        //Is the problem that it can't access to the database?
        mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', {$itemId}, {$qty})");
    } else {
        // This item already exists in the users cart,
        // we will update it instead
        UpdateItem($itemId, $qty);
    }
}