<?php
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
include '../../config.php';

$id = $_POST['id'];
$nama = $_POST['nama'];

$query = "UPDATE kategori_produk SET nama='$nama' WHERE id=$id";
if (mysqli_query($conn, $query)) {
    $_SESSION['alert'] = ['type' => 'success', 'message' => 'Kategori berhasil diupdate.'];
} else {
    $_SESSION['alert'] = ['type' => 'danger', 'message' => 'Gagal mengupdate kategori.'];
}

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