<?php
include 'db.php'; // Database connection

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $name = $_POST['name'];

    $stmt = $pdo->prepare("INSERT INTO categories (name) VALUES (?)");
    if ($stmt->execute([$name])) {
        echo '<div class="alert alert-success" role="alert">Category added successfully!</div>';
    } else {
        echo '<div class="alert alert-danger" role="alert">Error adding category.</div>';
    }
}
?>

<form method="POST" class="container mt-4">
    <div class="mb-3">
        <label for="categoryName" class="form-label">Category Name</label>
        <input type="text" class="form-control" id="categoryName" name="name" required>
    </div>
    <button type="submit" class="btn btn-primary">Add Category</button>
</form>
