<?php
session_start();
include 'config/koneksi.php';

if (!isset($_SESSION['admin_logged_in'])) {
  header("Location: login_admin.php");
  exit;
}

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;

// Hapus gambar tambahan
$conn->query("DELETE FROM produk_gambar WHERE produk_id = $id");

// Hapus varian
$conn->query("DELETE FROM produk_varian WHERE produk_id = $id");

// Hapus produk utama
$conn->query("DELETE FROM produk WHERE id = $id");

header("Location: admin_dashboard.php");
exit;
