One Hat Cyber Team
Your IP :
216.73.216.186
Server IP :
84.32.84.222
Server :
Linux in-mum-web1837.main-hosting.eu 5.14.0-503.34.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 27 06:00:50 EDT 2025 x86_64
Server Software :
LiteSpeed
PHP Version :
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
u322583024
/
domains
/
awaha.in
/
public_html
/
Edit File:
fetch_cart1_items.php
<?php session_name('vaishnavi_awaha'); session_start(); header('Content-Type: application/json'); include 'admin/connection.inc.php'; if (!$conn) { echo json_encode(['success' => false, 'message' => 'Database connection failed']); exit; } if (isset($_SESSION['user_id'])) { $user_id = $_SESSION['user_id']; // Fetch cart1 items from the database $stmt = $conn->prepare("SELECT c.product_id, c.quantity, p.product_name, p.product_price, p.product_img FROM cart1 c JOIN products p ON c.product_id = p.id WHERE c.user_id = ? AND c.deleted_at IS NULL;"); $stmt->bind_param('i', $user_id); if ($stmt->execute()) { $result = $stmt->get_result(); $cart_items = []; while ($row = $result->fetch_assoc()) { $cart_items[] = $row; } echo json_encode(['success' => true, 'cart_items' => $cart_items]); } else { echo json_encode(['success' => false, 'message' => 'Failed to fetch cart1 items']); } $stmt->close(); } else { // Fetch from cookies for guest users $cart = isset($_COOKIE['cart1']) ? json_decode($_COOKIE['cart1'], true) : []; $cart_items = []; foreach ($cart as $product_id => $quantity) { $stmt = $conn->prepare("SELECT id as product_id, product_name, product_price, product_img FROM products WHERE id = ?"); $stmt->bind_param('i', $product_id); $stmt->execute(); $result = $stmt->get_result(); if ($row = $result->fetch_assoc()) { $row['quantity'] = $quantity; $cart_items[] = $row; } $stmt->close(); } echo json_encode(['success' => true, 'cart_items' => $cart_items]); } $conn->close(); ?>
Simpan