<!----------------------------------Login------------------------------------>
<?php
include 'php/db_connection.php';

// শুধুমাত্র লগইন করা ইউজার পেজ দেখতে পারবে
if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

$userName = $_SESSION['user_name'];
$role = $_SESSION['role']; // ✅ এখানে role সেভ করা হচ্ছে
$userId = $_SESSION['user_id'];


$isAdmin = ($_SESSION['role'] == 'admin');

?>

<!---------------------------------কন্টেন------------------------------------>

<?php

// Check if the product ID is provided
if (isset($_GET['id'])) {
    $product_id = $_GET['id'];
    
    // Prepare and execute the SQL statement
    $stmt = $con->prepare("SELECT id, name AS description, price FROM product WHERE id = ?");
    $stmt->bind_param("i", $product_id);
    $stmt->execute();
    
    // Fetch the result
    $result = $stmt->get_result();
    $product = $result->fetch_assoc();

    // Return the product details as JSON
    echo json_encode($product);
} else {
    echo json_encode(null); // No product ID provided
}

$con->close();
