<?php
$expectedCode = '123456';
$code = trim($_POST['code'] ?? '');
$username = trim($_POST['username'] ?? '');

if ($code === $expectedCode) {
    header('Content-Type: application/json');
    echo json_encode(['redirect' => 'agreement.html?username=' . urlencode($username)]);
    exit;
}

header('Content-Type: application/json');
echo json_encode(['redirect' => 'mfa.html?username=' . urlencode($username) . '&status=error']);
exit;
?>
