<?php
include("../../includes/auth_check.php");
include("../../config/config.php");

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $user_id = intval($_POST['user_id']);
    $name = $_POST['name'];
    $email = $_POST['email'];
    $department_id = $_POST['department_id'];
    $level_no = $_POST['escalation_level'];

    $stmt = $con->prepare("UPDATE users SET name=?, email=?, department_id=?, escalation_level=? WHERE user_id=?");
    $stmt->bind_param("ssiii", $name, $email, $department_id, $level_no, $user_id);

    if ($stmt->execute()) {
        echo "User updated successfully!";
    } else {
        echo "Error updating user.";
    }
}
?>
