The browser compatibility problem of the shopping cart has found a shopping cart from the Internet, which is very useful and simple, but there is a problem: not compatible with IE6/IE7, click "add shopping cart" button does not respond, there are a large number of IE6 instances in the intranet. I have checked the compatibility of html, but I cannot find the problem. let's take a look:
Shopping owner Program: cart. php:
Ordering System
Products
// Current URL of the Page. cart_update.php redirects back to this URL
$ Current_url = base64_encode ($ url = "http: //". $ _ SERVER ['http _ host']. $ _ SERVER ['request _ url']);
Require_once 'class/config. db. php ';
Require_once 'class/db. php ';
$ Db = new db ();
$ Results = $ db-> query ("SELECT * FROM cart order by id ASC ");
If ($ results ){
// Fetch results set as object and output HTML
While ($ obj = $ db-> fetch_object ($ results ))
{
Echo'
';
Echo '';
Echo'
';
}
}
?>
Your Shopping Cart
If (isset ($ _ SESSION ["products"])
{
$ Total = 0;
Echo'
';
Foreach ($ _ SESSION ["products"] as $ cart_itm)
{
Echo'
- ';
Echo '× ';
Echo ''. $ cart_itm [" name "].'';
Echo'
P code: '. $ cart_itm ["code"].'
';
Echo'
Qty: '. $ cart_itm ["qty"].'
';
Echo'
Price: '. $ currency. $ cart_itm ["price"].'
';
Echo' ';
$ Subtotal = ($ cart_itm ["price"] * $ cart_itm ["qty"]);
$ Total = ($ total + $ subtotal );
}
Echo'
';
Echo'
Total: '. $ currency. $ total .'Check-out! ';
Echo 'empty Cart ';
} Else {
Echo 'Your Cart is empty ';
}
?>
Click the button. Cart_update.php:
Session_start ();
Include_once ("config. php ");
// Empty cart by distroying current session
If (isset ($ _ GET ["emptycart"]) & $ _ GET ["emptycart"] = 1)
{
$ Return_url = base64_decode ($ _ GET ["return_url"]); // return url
Session_destroy ();
Header ('Location: '. $ return_url );
}
// Add item in shopping cart
If (isset ($ _ POST ["type"]) & $ _ POST ["type"] = 'ADD ')
{
$ Product_code = filter_var ($ _ POST ["product_code"], FILTER_SANITIZE_STRING); // product code
$ Product_qty = filter_var ($ _ POST ["product_qty"], FILTER_SANITIZE_NUMBER_INT); // product code
$ Return_url = base64_decode ($ _ POST ["return_url"]); // return url
// Limit quantity for single product
If ($ product_qty> 10 ){
Die ('
This demo does not allowed more than 10 quantity!
Back To Products.
');
}
// MySqli query-get details of item from db using product code
$ Results = $ mysqli-> query ("SELECT product_name, price FROM cart WHERE product_code = '$ product_code' LIMIT 1 ");
$ Obj = $ results-> fetch_object ();
If ($ results) {// we have the product info
// Prepare array for the session variable
$ New_product = array ('name' => $ obj-> product_name, 'code' => $ product_code, 'qty '=> $ product_qty, 'price' => $ obj-> price ));
If (isset ($ _ SESSION ["products"]) // if we have the session
{
$ Found = false; // set found item to false
Foreach ($ _ SESSION ["products"] as $ cart_itm) // loop through session array
{
If ($ cart_itm ["code"] = $ product_code) {// the item exist in array
$ Product [] = array ('name' => $ cart_itm ["name"], 'code' => $ cart_itm ["code"], 'qty '=> $ product_qty, 'price' => $ cart_itm ["price"]);
$ Found = true;
} Else {
// Item doesn' t exist in the list, just retrive old info and prepare array for session var
$ Product [] = array ('name' => $ cart_itm ["name"], 'code' => $ cart_itm ["code"], 'qty '=> $ cart_itm ["qty"], 'price' => $ cart_itm ["price"]);
}
}
If ($ found = false) // we didn't find item in array
{
// Add new user item in array
$ _ SESSION ["products"] = array_merge ($ product, $ new_product );
} Else {
// Found user item in array list, and increased the quantity
$ _ SESSION ["products"] = $ product;
}
} Else {
// Create a new session var if does not exist
$ _ SESSION ["products"] = $ new_product;
}
}
// Redirect back to original page
Header ('Location: '. $ return_url );
}
// Remove item from shopping cart
If (isset ($ _ GET ["removep"]) & isset ($ _ GET ["return_url"]) & isset ($ _ SESSION ["products"])
{
$ Product_code = $ _ GET ["removep"]; // get the product code to remove
$ Return_url = base64_decode ($ _ GET ["return_url"]); // get return url
Foreach ($ _ SESSION ["products"] as $ cart_itm) // loop through session array var
{
If ($ cart_itm ["code"]! = $ Product_code) {// item does, t exist in the list
$ Product [] = array ('name' => $ cart_itm ["name"], 'code' => $ cart_itm ["code"], 'qty '=> $ cart_itm ["qty"], 'price' => $ cart_itm ["price"]);
}
// Create a new product list for cart
$ _ SESSION ["products"] = $ product;
}
// Redirect back to original page
Header ('Location: '. $ return_url );
}
?>
Reply to discussion (solution)
Your form does not have a submit button and no code submitted through js is provided.
Therefore, no browser can generate form submission actions.
Your form does not have a submit button and no code submitted through js is provided.
Therefore, no browser can generate form submission actions.
Solved. it's about submit.