<?php
include('includes/dbconnection.php');

if (isset($_POST['edit_id'])) {
    $edit_id = intval($_POST['edit_id']);
    $stmt = $con->prepare("SELECT * FROM events WHERE id = ?");
    $stmt->bind_param("i", $edit_id);
    $stmt->execute();
    $result = $stmt->get_result();
    $row = $result->fetch_assoc();
    $stmt->close();
?>
    <form id="updateEventForm">
        <input type="hidden" name="event_id" value="<?php echo htmlentities($row['id']); ?>">
        <div class="form-group">
            <label>Event Name</label>
            <input type="text" class="form-control" name="edit_title" value="<?php echo htmlentities($row['title']); ?>" required>
        </div>
        <div class="form-group">
            <label>Event Date</label>
            <input type="date" class="form-control" name="edit_event_date" value="<?php echo htmlentities($row['event_date']); ?>" required>
        </div>
        <button type="submit" class="btn btn-success">Update</button>
    </form>
<?php } ?>
