<?php
include "config.php";
$id=$_GET['id'];

if(isset($_POST['update'])){
$name=$_POST['name'];
$age=$_POST['age'];
$gender=$_POST['gender'];
$mobile=$_POST['mobile'];

mysqli_query($conn,
"UPDATE patients SET
name='$name',age='$age',gender='$gender',mobile='$mobile'
WHERE id=$id");

header("Location:patients.php");
}

$data=mysqli_fetch_assoc(mysqli_query($conn,"SELECT * FROM patients WHERE id=$id"));
include "header.php";
?>

<h4>Edit Patient</h4>

<form method="post">
<input class="form-control mb-2" name="name" value="<?=$data['name']?>" required>
<input class="form-control mb-2" name="age" value="<?=$data['age']?>" required>
<input class="form-control mb-2" name="gender" value="<?=$data['gender']?>" required>
<input class="form-control mb-2" name="mobile" value="<?=$data['mobile']?>" required>

<button class="btn btn-success" name="update">Update</button>
</form>

<?php include "footer.php"; ?>
