Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_SESSION))
- {
- session_start();
- }
- ?>
- <title>shopping cart</title>
- <link href="http://fonts.googleapis.com/css?family=Abel" rel="stylesheet" type="text/css" />
- <link href="../styles/default.css" rel="stylesheet" type="text/css" media="all" />
- </head>
- <body>
- <?php
- if (!isset($_SESSION))
- {
- session_start();
- }
- require_once "../database/dbconn.php";
- require_once "../includes/functions.php";
- $Product_code = $_POST['Product_code'];
- $qtyordered = $_POST['qtyordered'];
- $Product_price = $_POST['Product_price'];
- $Product_name = $_POST['Product_name'];
- $error_message = "";
- $error_message .= validate_qtyordered($qtyordered);
- if ($error_message != "")
- include_once "../shop/catalogue.php";
- else
- {
- //echo $qtyordered . $Product_price . $Product_code . $Product_name;
- //worked here
- $session_id = session_id();
- $UserID = $_SESSION['UserID'];
- //worked here
- $query = "SELECT * FROM tblcart WHERE session_id = '$session_id' AND UserID = '$UserID' AND Product_code = '$Product_code'";
- $result = mysql_query($query) or die(mysql_error());
- $rows = mysql_num_rows($result);
- //$rows = 2; <- set the value twice to test for the mulitpal items in cart
- if ($rows > 0)
- {
- $error_message .= "Product is already in cart";
- require_once "../shop/catalogue.php";
- }
- //worked here
- else
- {
- $query = "INSERT into tblcart (session_id, UserID, Product_code, QTY, Product_price) VALUES ('$session_id', '$UserID', '$Product_code', '$qtyordered', '$Product_price')";
- $result = mysql_query($query) or die(mysql_error());
- $row = mysql_affected_rows();
- if ($row > 0)
- {
- if ($qtyordered >1)
- {
- echo $qtyordered . " " . $Product_name . "s have";
- }
- else
- {
- echo $qtyordered . " " . $Product_name . " has";
- }
- echo " been added to your cart";
- $_SESSION['cart'] = true;
- ?>
- <p><a href="../shop/catalogue.php"> Continue shopping</a></p>
- <p><a href="shopcart.php"> view shopping cart</a></p>
- <?php
- }
- else
- {
- echo "error";
- }
- }
- }
- ?>
- <!--</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div id="footer" class="container">
- <p>© admin login <a href="../admin/adminlogon.php">here</a></p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment