<?php
header('Content-Type: application/json');

$email = '';
if (!empty($_POST['user']['email'])) {
    $email = sanitizeInput($_POST['user']['email']);
} elseif (!empty($_POST['email'])) {
    $email = sanitizeInput($_POST['email']);
}

if (empty($email)) {
    echo json_encode(['success' => false, 'message' => 'Email is required']);
    exit;
}

$_SESSION['signin_email'] = $email;

echo json_encode([
    'success' => true,
    'message' => 'Continue to password',
    'redirect' => '/signin/password'
]);
