<?php
session_start();
include "config.php";

if (!isset($_SESSION['user'])) {
    echo '<script>window.location.href = "index.php";</script>';
    exit();
}

// Get user details from session
$user = $_SESSION['user'];

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = $_POST['id'];
    $status = $_POST['status'];
    $atf = $_POST['atf'];

    $query = "UPDATE cyber_police SET status='$status', atf='$atf' WHERE id='$id'";

      if (mysqli_query($con, $query)) {
        echo '<script>alert("Record inserted successfully!"); window.location.href = "atf.php";</script>';
    } else {
        echo '<script>alert("Error inserting record: ' . mysqli_error($con) . '");</script>';
    }
    exit();
}
?>