klik untuk menyalin
👇
<?php
include 'db.php';
if($_SESSION['role']!='seller'){ echo "Bukan seller!"; exit; }
if($_SERVER['REQUEST_METHOD']=='POST'){
$shop_id = $_POST['shop_id'];
$name = $_POST['product_name'];
$price = $_POST['price'];
$stock = $_POST['stock'];
$conn->query("INSERT INTO products (shop_id, product_name, price, stock, created_at)
VALUES ('$shop_id','$name','$price','$stock',NOW())");
echo "Produk berhasil ditambahkan!";
}
?>
<form method="post">
Shop ID: <input type="text" name="shop_id"><br>
Nama Produk: <input type="text" name="product_name"><br>
Harga: <input type="number" name="price"><br>
Stok: <input type="number" name="stock"><br>
<button type="submit">Tambah</button>
</form>
Tidak ada komentar:
Posting Komentar