<?php

    // header('Content-Type: application/json');
    include '../db_conn.php';

    $eventID = [
        'id' => $_POST['id']
    ];

    $query = "SELECT * FROM Events WHERE event_id=:id LIMIT 1";

    $statement = $db->prepare($query);

    try {
        $statement->execute(array(
            "id" => $eventID['id']
        ));
    } catch (PDOException $ex2) {
        echo $query . "<br>" . $ex2;
        die("Error connecting to SQL server.");
    }
    
    $result = $statement->fetch(PDO::FETCH_ASSOC);

    $result['title'] = "DEPRECATED API!";

    echo json_encode($result);

    // Use js to go back 1 page
    //header("location:javascript://history.go(-1)");

    // Then execute the query, give user feedback, and updateEvents();

    //echo '<script>updateEvents();</script>';
?>
