<?php
include 'db.php';
include 'auth.php';
require_right('Manage Categories');



if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $stmt = $conn->prepare("INSERT INTO categories (name) VALUES (?)");
    $stmt->bind_param("s", $_POST['name']);
    $stmt->execute();
    header("Location: category_list.php");
    exit;
}
include 'layout.php';
?>
<div class="page-wrapper">
    <div class="content">
        <h4>Add Category</h4>
        <form method="POST">
            <input type="text" name="name" placeholder="Category Name" class="form-control mb-3" required>
            <div class="text-end"><button class="btn btn-primary">Save</button></div>
        </form>
    </div>
</div>
