<?php
require_once "includes/config.php";

// ❌ koi include header/footer NAHI

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header("Location: /myukstore/index.php");
    exit;
}

$id  = (int)($_POST['id'] ?? 0);
$qty = (int)($_POST['qty'] ?? 1);

if ($id <= 0 || $qty <= 0) {
    header("Location: /myukstore/index.php");
    exit;
}

if (!isset($_SESSION['cart'])) {
    $_SESSION['cart'] = [];
}

$_SESSION['cart'][$id] = ($_SESSION['cart'][$id] ?? 0) + $qty;

// ✅ MUST REDIRECT
header("Location: /myukstore/cart.php");
exit;
