BLACKSITE
:
216.73.217.4
:
104.37.75.190 / alpenpass.ca
:
Linux server3.pointsplan.com 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
:
/
home
/
apca
/
public_html
/
Upload File:
files >> /home/apca/public_html/delete_from_cart.php
<?php session_start(); include('includes/config.php'); // Ensure the user is logged in if (!isset($_SESSION['id'])) { die("Unauthorized access."); } $user_id = $_SESSION['id']; // Validate and sanitize the product ID from the GET parameter if (!isset($_GET['product_id']) || !is_numeric($_GET['product_id'])) { die("Invalid product ID."); } $product_id = (int)$_GET['product_id']; try { // Delete the item from the cart for the specific user and product $query = $dbh->prepare("DELETE FROM cart WHERE user_id = :user_id AND product_id = :product_id"); $query->execute([ ':user_id' => $user_id, ':product_id' => $product_id, ]); // Check if any rows were affected if ($query->rowCount() > 0) { $_SESSION['success_message'] = "Item successfully removed from the cart."; } else { $_SESSION['error_message'] = "Item not found in your cart."; } // Redirect back to the cart page header("Location: cart.php"); exit(); } catch (Exception $e) { // Log the error and redirect with an error message error_log($e->getMessage()); $_SESSION['error_message'] = "An error occurred while removing the item."; header("Location: cart.php"); exit(); }