['name' => 'Demo User', 'balance' => 9.99, 'verifications' => 10, 'isPaid' => false], 'admin@agesmart.eu' => ['name' => 'Admin User', 'balance' => 24.50, 'verifications' => 50, 'isPaid' => true], ]; $error = ''; $mode = 'login'; // login | signup // ── Already logged in → go to dashboard ──────────────────────────────────── if (!empty($_SESSION['user'])) { header('Location: dashboard.php'); exit; } // ── Handle form POST ──────────────────────────────────────────────────────── if ($_SERVER['REQUEST_METHOD'] === 'POST') { $mode = $_POST['mode'] ?? 'login'; $email = strtolower(trim($_POST['email'] ?? '')); $pass = $_POST['password'] ?? ''; $name = trim($_POST['name'] ?? ''); $conf = $_POST['confirm'] ?? ''; if ($mode === 'login') { // Check demo accounts if (isset($DEMO[$email]) && strlen($pass) >= 4) { $_SESSION['user'] = array_merge(['email' => $email], $DEMO[$email]); header('Location: dashboard.php'); exit; } // Check stored users $users = load_users($USERS_FILE); if (isset($users[$email]) && $users[$email]['password'] === hash('sha256', $pass)) { $u = $users[$email]; $_SESSION['user'] = ['email'=>$email,'name'=>$u['name'],'balance'=>$u['balance'],'verifications'=>$u['verifications'],'isPaid'=>$u['isPaid']]; header('Location: dashboard.php'); exit; } $error = 'Invalid email or password.'; } else { // signup if (strlen($pass) < 6) { $error = 'Password must be at least 6 characters.'; } elseif ($pass !== $conf) { $error = 'Passwords do not match.'; } elseif (empty($name)) { $error = 'Please enter your full name.'; } elseif (isset($DEMO[$email])) { $error = 'An account with this email already exists.'; } else { $users = load_users($USERS_FILE); if (isset($users[$email])) { $error = 'An account with this email already exists.'; } else { $users[$email] = [ 'name' => $name, 'password' => hash('sha256', $pass), 'balance' => 0, 'verifications' => 0, 'isPaid' => false, ]; save_users($USERS_FILE, $users); $_SESSION['user'] = ['email'=>$email,'name'=>$name,'balance'=>0,'verifications'=>0,'isPaid'=>false]; header('Location: dashboard.php'); exit; } } } } $mode = $_POST['mode'] ?? 'login'; ?> AgeSmart — Sign In
Welcome back
Sign in to your AgeSmart account
Create your account
Start verifying ages in minutes
Don't have an account? Sign up
Already have an account? Sign in