<?php
require_once 'db/config.php';

if (isset($_POST['add'])) {
    $name = $_POST['name'];
    $color = $_POST['color'];
    $display_order = $_POST['display_order'];
    
    $pdo = db();
    $stmt = $pdo->prepare("INSERT INTO event_types (name, color, display_order) VALUES (?, ?, ?)");
    $stmt->execute([$name, $color, $display_order]);
    
    session_start();
    $_SESSION['success_message'] = 'Event type added successfully.';
    header('Location: event_types.php');
    exit;
}
?>