Let's ask a question: cart. php & lt; on the shopping cart page ;? Phpdefine (ACCESE, 1); require (.. init. php); $ _ GET [gid] & nbsp; (int) $ _ GET [gid]; $ _ GET [num] & nbsp; (int) $ _ GET [num]; $ goo to ask a question
We are creating a shopping cart.
Cart. php on the shopping cart page
Define ('accesss', 1 );
Require ('../init. php ');
$ _ GET ['gid'] = (int) $ _ GET ['gid'];
$ _ GET ['num'] = (int) $ _ GET ['num'];
$ Goods = new goodsModel ();
$ Goods-> db ();
$ Cart = cart: getCart ();
Switch ($ _ GET ['AC']) {
// Add product
Case 'buy ':{
$ Result = $ goods-> select_goods ("g_id = $ _ GET [gid] and g_sale = 1 and g_del = 0 ");
$ G = $ goods-> db-> fetch_array ($ result );
// This product is available
If (! Empty ($ g) {// determines whether the product exists
If ($ g ['G _ no'] <$ _ GET ['num']) {// judge the inventory
$ Type = 'error ';
$ Msg = 'failed to add the item to the shopping cart (the inventory may be insufficient or the administrator swallowed it privately )';
Include (ROOT. 'View/home/tip.html ');
Exit;
}
// The product exists.
$ Cart-> addItem ("$ g [g_id]", "$ g [g_name]", "$ g [g_price]", "$ _ GET [num]"); // ---------------------- This row reports an error
} Else {
$ Type = 'error ';
$ Msg = 'failed to add it to the shopping cart (it may be dismounted, deleted, or swallowed by the administrator )';
Include (ROOT. 'View/home/tip.html ');
Exit;
}
Break;
}
}
$ Title = 'Shopping cart-mall system ';
$ Path = 'cart ';
Include (ROOT. 'View/home/cart.html ');