<?php
include "config.php";

$id = $_GET['id'];

if(isset($_POST['save'])){
    $time = $_POST['time'];
    mysqli_query($conn,"UPDATE appointments SET visit_time='$time' WHERE id='$id'");
    header("Location: appointments.php");
    exit;
}

$q = mysqli_query($conn,"SELECT visit_time FROM appointments WHERE id='$id'");
$row = mysqli_fetch_assoc($q);
?>

<h2>Change Appointment Time</h2>

<form method="post">
<input type="time" name="time" value="<?php echo $row['visit_time']; ?>" required>
<br><br>
<button name="save">Update Time</button>
</form>