diff --git a/header.php b/header.php index 856d55e..67023ae 100644 --- a/header.php +++ b/header.php @@ -1,588 +1,593 @@ - - - - 0) { - $_SESSION['username'] = $USERNAME; - $l_insert_to_log_user = "INSERT into `tbluserlog` (Username,LoginTime,Logout,Status) VALUES ('$USER','0',date('Y-m-d H:i:s'),'1')"; - $result_l_insert_to_log_user = mysqli_query($con, $l_insert_to_log_user); - if (!isset($_SESSION['selectedproduct'])) { - header('location: myprofile.php'); - } //!isset($_SESSION['selectedproduct']) - else { - $PRODUCT_ID = $_SESSION['selectedproduct']; - $PRODUCT_QUANTITY = $_SESSION['selectedquantity']; - $l_insert_to_cart = "INSERT into `tblcart` (ProductID,Username,Quantity) VALUES (" . $PRODUCT_ID . ",'$USER'," . $PRODUCT_QUANTITY . ")"; - $result_l_insert_to_cart = mysqli_query($con, $l_insert_to_cart); - header('location: cart.php'); - } - } //mysqli_num_rows($results_l_select_user) > 0 - else if (mysqli_num_rows($results_l_select_admin) > 0) { - $_SESSION['username'] = $USERNAME; - $l_insert_to_log_admin = "INSERT into `tbluserlog` (Username,LoginTime,Logout,Status) VALUES ('$USER','0',date('Y-m-d H:i:s'),'1')"; - $result_l_insert_to_log_admin = mysqli_query($con, $l_insert_to_log_admin); - header('location: admin/manageorders.php'); - } //mysqli_num_rows($results_l_select_admin) > 0 - else { - $MESSAGE_LOGIN = "Username or Password is Invalid"; - } - } -} //isset($_POST['login']) -/////////////////////////////Continue as a guest///////////////////////////// -if (isset($_POST['continueguest'])) { - $PRODUCT_ID = $_SESSION['selectedproduct']; - $PRODUCT_QUANTITY = $_SESSION['selectedquantity']; - $_SESSION['totalproducts'] = $PRODUCT_QUANTITY; - $generate_delivery_id_guest = mysqli_query($con, "SELECT delivery_id FROM (SELECT FLOOR(RAND() * 99999) AS delivery_id UNION SELECT FLOOR(RAND() * 99999) AS random_num) AS numbers_mst_plus_1 WHERE `delivery_id` NOT IN (SELECT DeliveryID FROM tblorder) LIMIT 1"); - $result_generate_delivery_id_guest = mysqli_fetch_assoc($generate_delivery_id_guest); - $DELIVERY_ID_GUEST = $result_generate_delivery_id_guest['delivery_id']; - $_SESSION['deliveryid'] = $DELIVERY_ID_GUEST; - $l_select_total_price = "SELECT ProductPrice FROM `tblproducts` WHERE ProductID='" . $PRODUCT_ID . "' "; - $result_l_select_total_price = mysqli_query($con, $l_select_total_price); - $total_price = mysqli_fetch_assoc($result_l_select_total_price); - $PRICE = $total_price['ProductPrice']; - $TOTAL_PRICE = $PRICE * $PRODUCT_QUANTITY; - $_SESSION['totalprice'] = $TOTAL_PRICE; - $l_insert_order = "INSERT into `tblorder` (ProductID,Quantity,Username,DeliveryID) VALUES (" . $PRODUCT_ID . "," . $PRODUCT_QUANTITY . ",'Guest'," . $DELIVERY_ID_GUEST . ")"; - $result_l_insert_ordert = mysqli_query($con, $l_insert_order); - header("Location: checkout.php"); -} //isset($_POST['continueguest']) -?> - - - - - - - - - $selectionid) { - $update_cart = "UPDATE tblcart SET Quantity='" . $_POST['quantity'][$idx] . "' WHERE SelectionID='" . $selectionid . "'"; - $result_update_cart = mysqli_query($con, $update_cart); - } //$_POST['selectedvalues'] as $idx => $selectionid - header("Location: cart.php"); -} //isset($_POST['updateitem']) -/////////////////////////////checkout products from cart///////////////////////////// -if (isset($_POST['checkout'])) { - $generate_delivery_id = mysqli_query($con, "SELECT delivery_id FROM (SELECT FLOOR(RAND() * 99999) AS delivery_id UNION SELECT FLOOR(RAND() * 99999) AS random_num) AS numbers_mst_plus_1 WHERE `delivery_id` NOT IN (SELECT DeliveryID FROM tblorder) LIMIT 1"); - $result_generate_delivery_id = mysqli_fetch_assoc($generate_delivery_id); - $DELIVERY_ID = $result_generate_delivery_id['delivery_id']; - $USER = $_SESSION['username']; - $insert_order = "INSERT INTO tblorder (`ProductID`, `Quantity`, `Username`, `DeliveryID`) SELECT `ProductID`, `Quantity`, `Username`, '" . $DELIVERY_ID . "' FROM tblcart WHERE `Username` = '" . $USER . "' "; - $_SESSION['deliveryid'] = $DELIVERY_ID; - $result_insert_order = mysqli_query($con, $insert_order); - header("Location: checkout.php"); -} //isset($_POST['checkout']) -/////////////////////////////Removal of products from cart///////////////////////////// -if (isset($_POST["removeitem"])) { - $IMPLODE_VALUES = $_POST['checkedvalues']; - $CHECKED_VALUES_REMOVE = implode(",", $IMPLODE_VALUES); - $remove_cart_items = "DELETE FROM `tblcart` WHERE SelectionID in ($CHECKED_VALUES_REMOVE)"; - $result_remove_cart_items = mysqli_query($con, $remove_cart_items); - header("Location: cart.php"); -} //isset($_POST["removeitem"]) - -if (isset($_POST["continueshopping"])) { - header("Location: pnb.php"); -} //isset($_POST["continueshopping"]) - -?> - - - - - - - - - - - + + + + 0) { + $_SESSION['username'] = $USERNAME; + $l_insert_to_log_user = "INSERT into `tbluserlog` (Username,LoginTime,Logout,Status) VALUES ('$USER','0',date('Y-m-d H:i:s'),'1')"; + $result_l_insert_to_log_user = mysqli_query($con, $l_insert_to_log_user); + if (!isset($_SESSION['selectedproduct'])) { + header('location: myprofile.php'); + } //!isset($_SESSION['selectedproduct']) + else { + $PRODUCT_ID = $_SESSION['selectedproduct']; + $PRODUCT_QUANTITY = $_SESSION['selectedquantity']; + $l_insert_to_cart = "INSERT into `tblcart` (ProductID,Username,Quantity) VALUES (" . $PRODUCT_ID . ",'$USER'," . $PRODUCT_QUANTITY . ")"; + $result_l_insert_to_cart = mysqli_query($con, $l_insert_to_cart); + header('location: cart.php'); + } + } //mysqli_num_rows($results_l_select_user) > 0 + else if (mysqli_num_rows($results_l_select_admin) > 0) { + $_SESSION['username'] = $USERNAME; + $l_insert_to_log_admin = "INSERT into `tbluserlog` (Username,LoginTime,Logout,Status) VALUES ('$USER','0',date('Y-m-d H:i:s'),'1')"; + $result_l_insert_to_log_admin = mysqli_query($con, $l_insert_to_log_admin); + header('location: admin/manageorders.php'); + } //mysqli_num_rows($results_l_select_admin) > 0 + else { + $MESSAGE_LOGIN = "Username or Password is Invalid"; + } + } +} //isset($_POST['login']) +/////////////////////////////Continue as a guest///////////////////////////// +if (isset($_POST['continueguest'])) { + $PRODUCT_ID = $_SESSION['selectedproduct']; + $PRODUCT_QUANTITY = $_SESSION['selectedquantity']; + $_SESSION['totalproducts'] = $PRODUCT_QUANTITY; + $generate_delivery_id_guest = mysqli_query($con, "SELECT delivery_id FROM (SELECT FLOOR(RAND() * 99999) AS delivery_id UNION SELECT FLOOR(RAND() * 99999) AS random_num) AS numbers_mst_plus_1 WHERE `delivery_id` NOT IN (SELECT DeliveryID FROM tblorder) LIMIT 1"); + $result_generate_delivery_id_guest = mysqli_fetch_assoc($generate_delivery_id_guest); + $DELIVERY_ID_GUEST = $result_generate_delivery_id_guest['delivery_id']; + $_SESSION['deliveryid'] = $DELIVERY_ID_GUEST; + $l_select_total_price = "SELECT ProductPrice FROM `tblproducts` WHERE ProductID='" . $PRODUCT_ID . "' "; + $result_l_select_total_price = mysqli_query($con, $l_select_total_price); + $total_price = mysqli_fetch_assoc($result_l_select_total_price); + $PRICE = $total_price['ProductPrice']; + $TOTAL_PRICE = $PRICE * $PRODUCT_QUANTITY; + $_SESSION['totalprice'] = $TOTAL_PRICE; + $l_insert_order = "INSERT into `tblorder` (ProductID,Quantity,Username,DeliveryID) VALUES (" . $PRODUCT_ID . "," . $PRODUCT_QUANTITY . ",'Guest'," . $DELIVERY_ID_GUEST . ")"; + $result_l_insert_ordert = mysqli_query($con, $l_insert_order); + header("Location: checkout.php"); +} //isset($_POST['continueguest']) +?> + + + + + + + 0) { + $MESSAGE = "We have found ('" . $ROWS . "') that matches:'" . $SEARCHED_VALUE . "' "; + $CATEGORY_SELECTED = '5'; + } else { + $MESSAGE = "No matching products found."; + $CATEGORY_SELECTED = ''; // Reset the category selection if no results found + } +} +?> + + $selectionid) { + $update_cart = "UPDATE tblcart SET Quantity='" . $_POST['quantity'][$idx] . "' WHERE SelectionID='" . $selectionid . "'"; + $result_update_cart = mysqli_query($con, $update_cart); + } //$_POST['selectedvalues'] as $idx => $selectionid + header("Location: cart.php"); +} //isset($_POST['updateitem']) +/////////////////////////////checkout products from cart///////////////////////////// +if (isset($_POST['checkout'])) { + $generate_delivery_id = mysqli_query($con, "SELECT delivery_id FROM (SELECT FLOOR(RAND() * 99999) AS delivery_id UNION SELECT FLOOR(RAND() * 99999) AS random_num) AS numbers_mst_plus_1 WHERE `delivery_id` NOT IN (SELECT DeliveryID FROM tblorder) LIMIT 1"); + $result_generate_delivery_id = mysqli_fetch_assoc($generate_delivery_id); + $DELIVERY_ID = $result_generate_delivery_id['delivery_id']; + $USER = $_SESSION['username']; + $insert_order = "INSERT INTO tblorder (`ProductID`, `Quantity`, `Username`, `DeliveryID`) SELECT `ProductID`, `Quantity`, `Username`, '" . $DELIVERY_ID . "' FROM tblcart WHERE `Username` = '" . $USER . "' "; + $_SESSION['deliveryid'] = $DELIVERY_ID; + $result_insert_order = mysqli_query($con, $insert_order); + header("Location: checkout.php"); +} //isset($_POST['checkout']) +/////////////////////////////Removal of products from cart///////////////////////////// +if (isset($_POST["removeitem"])) { + $IMPLODE_VALUES = $_POST['checkedvalues']; + $CHECKED_VALUES_REMOVE = implode(",", $IMPLODE_VALUES); + $remove_cart_items = "DELETE FROM `tblcart` WHERE SelectionID in ($CHECKED_VALUES_REMOVE)"; + $result_remove_cart_items = mysqli_query($con, $remove_cart_items); + header("Location: cart.php"); +} //isset($_POST["removeitem"]) + +if (isset($_POST["continueshopping"])) { + header("Location: pnb.php"); +} //isset($_POST["continueshopping"]) + +?> + + + + + + + + + + +