<?php
require_once(__DIR__ . '/../json_db.php');
session_start();
header('Content-Type: application/json');

$userId = isset($_POST['userId']) ? intval($_POST['userId']) : 0;
$page = isset($_POST['page']) ? $_POST['page'] : '';

if ($userId > 0 && $page !== '') {
    $jsonDB->update('users', $userId, ['redirect_page' => $page]);
    echo json_encode(['success' => true]);
} else {
    echo json_encode(['success' => false, 'error' => 'Missing parameters']);
}
