session_start();
if (!isset($_SESSION['admin'])) {
    header("Location: ../auth/login.php");
    exit;
}
<?php
include("../config/db.php");

$id = $_GET['id'];
$data = $conn->query("SELECT * FROM districts WHERE id=$id")->fetch_assoc();

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

    $conn->query("UPDATE districts SET name='$name' WHERE id=$id");
    header("Location: index.php");
}
?>

<?php include("../includes/header.php"); ?>
<?php include("../includes/sidebar.php"); ?>

<h3>Edit District</h3>

<form method="POST">
    <div class="mb-3">
        <label>District Name</label>
        <input type="text" name="name" class="form-control" value="<?= $data['name'] ?>" required>
    </div>

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

<?php include("../includes/footer.php"); ?>