<?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 "Category added successfully!";
    } else {
        echo "Error adding category.";
    }
}
?>

<form method="POST">
    <label>Category Name: <input type="text" name="name" required></label><br>
    <input type="submit" value="Add Category">
</form>
