Browser compatibility issues for shopping carts

Source: Internet
Author: User
From the Internet to find a shopping cart, very easy to use, simple and convenient, but there is a problem: incompatible Ie6/ie7, click on the "Add Shopping cart" button did not respond, and the intranet has a lot of IE6, I looked at a bit, it should be the compatibility of HTML problems, but is not find the problem where, we help to see:

Shopping owner program: cart.php:



<title>Food ordering System</title>






Products



Current URL of the Page. Cart_update.php redirects back to the This URL
$current _url = base64_encode ($url = "http://". $_server[' http_host '].$_server[' Request_uri ']);
Require_once ' class/config.db.php ';
Require_once ' class/db.php ';
$DB =new db ();
$results = $db->query ("select * from the 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 '
    1. ';
      Echo 'x';
      Echo '

      '. $cart _itm["name"]. '

      ';
      Echo ' P code: '. $cart _itm["code"].
      Echo ' Qty: '. $cart _itm["Qty"].
      Echo ' Price: '. $currency. $cart _itm["Price"].
      Echo '
    2. ';
      $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 ';
}
?>





The link of the Submit button, the Point button did not respond. 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 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 has 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 does not give the code submitted via JS
So no browser can produce form submission actions

Your form does not have a submit button, and does not give the code submitted via JS
So no browser can produce form submission actions



Solved, it's a submit.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.