<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = $_POST['id'];
    $position = trim($_POST['position']);

    $file = 'users.json';
    $data = json_decode(file_get_contents($file), true);

    if (isset($data['users'][$id])) {
        $data['users'][$id]['position'] = $position;
        file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT));
    }
}

header("Location: admin.php");
exit;
