<?php
include "config.php"; // Ensure this connects to your database

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $id       = mysqli_real_escape_string($con, $_POST['id']);
    $spid     = mysqli_real_escape_string($con, $_POST['spid']);
    $name     = mysqli_real_escape_string($con, $_POST['name']);
    $address  = mysqli_real_escape_string($con, $_POST['address']);
    $landline = mysqli_real_escape_string($con, $_POST['landline']);
    $number   = mysqli_real_escape_string($con, $_POST['number']);
    $email    = mysqli_real_escape_string($con, $_POST['email']);

    $query = "UPDATE policestation 
              SET spid = '$spid',
                  p_name = '$name',
                  p_address = '$address',
                  p_landline = '$landline',
                  p_number = '$number',
                  p_email = '$email'
              WHERE id = '$id'";

    if (mysqli_query($con, $query)) {
                                                            echo '<script>window.location.href = "police_station.php";</script>';

        exit();
    } else {
        echo "Error: " . mysqli_error($con);
    }
}
?>