<?php include('config.php'); ?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title>Tambah Barang</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h2>Tambah Barang</h2>
    <form action="" method="POST">
        <div class="form-grup">
        Nama Barang: 
        <input type="text" name="nama_barang" required><br>
        Jenis Barang: <input type="text" name="jenis_barang" required><br>
        Harga: <input type="number" name="harga_barang" required><br>
        Stok: <input type="number" name="stok_barang" required><br>
        <button type="submit" name="submit">Simpan</button>
    </form>
    <?php
    if (isset($_POST['submit'])) {
        $nama_barang = $_POST['nama_barang'];
        $jenis_barang = $_POST['jenis_barang'];
        $harga_barang = $_POST['harga_barang'];
        $stok_barang = $_POST['stok_barang'];

        $query = "INSERT INTO barang (nama_barang, jenis_barang, harga_barang, stok_barang) VALUES ('$nama_barang', '$jenis_barang', '$harga_barang', '$stok_barang')";
        mysqli_query($conn, $query);
        header("Location: index.php");
    }
    ?>
</body>
</html>
