<?php
include 'config/koneksi.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $produk_id = (int)$_POST['produk_id'];
    $nama_varian = $conn->real_escape_string($_POST['nama_varian']);
    $harga = (int)$_POST['harga'];

    $sql = "INSERT INTO produk_varian (produk_id, nama_varian, harga) 
            VALUES ($produk_id, '$nama_varian', $harga)";
    if ($conn->query($sql)) {
        echo "✅ Varian berhasil ditambahkan.";
    } else {
        echo "❌ Gagal menambahkan varian: " . $conn->error;
    }
}
?>

<form method="post" class="checkout-form">
    <label>ID Produk</label>
    <input type="text" name="produk_id" required>

    <label>Nama Varian</label>
    <input type="text" name="nama_varian" required>

    <label>Harga Varian (Rp)</label>
    <input type="text" name="harga" required>

    <button type="submit" class="button">Tambah Varian</button>
</form>
