<?php

include "../../config/master.php";

/* Only Super Admin */

allowRoles([1]);

$id=$_GET['id'];

$data=mysqli_query($conn,"SELECT * FROM villages WHERE id='$id'");
$row=mysqli_fetch_assoc($data);

include "../layout/header.php";
include "../layout/sidebar.php";

if(isset($_POST['update']))
{

$village_name=$_POST['village_name'];
$pincode=$_POST['pincode'];

mysqli_query($conn,"UPDATE villages SET
village_name='$village_name',
pincode='$pincode'
WHERE id='$id'");

echo "<script>alert('Village Updated');</script>";
echo "<script>window.location='view_villages.php';</script>";

}
?>

<div class="main">

<h2>Edit Village</h2>

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

<label>Village Name</label>
<input type="text" name="village_name"
value="<?php echo $row['village_name']; ?>" required>

<label>Pincode</label>
<input type="text" name="pincode"
value="<?php echo $row['pincode']; ?>">

<button name="update" class="btn-save">Update Village</button>

</form>

</div>

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