<?php
include('../../includes/layout_inicio.php');
require_once('../../config/conexao.php');

// SALVAR
if($_POST){
    $nome = $_POST['nome'];
    $data = $_POST['data_evento'];

    $sql = "INSERT INTO eventos (nome, data_evento) VALUES (:nome, :data)";
    $stmt = $pdo->prepare($sql);
    $stmt->execute([
        'nome' => $nome,
        'data' => $data
    ]);

    header("Location: listar.php");
    exit;
}
?>

<h1>Criar Evento</h1>

<form method="POST" class="form">

    <label>Nome do Evento</label>
    <input type="text" name="nome" required>

    <label>Data do Evento</label>
    <input type="date" name="data_evento" required>

    <br><br>

    <button class="btn btn-primary">Salvar</button>
    <a href="listar.php" class="btn btn-danger">Cancelar</a>

</form>

<?php include('../../includes/layout_fim.php'); ?>