prepare("SELECT * FROM users WHERE username = ? OR email = ?"); $stmt->execute([$account, $account]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { if ($user['role'] === 'admin') { $error = __('login_admin_error'); } else { if (session_status() === PHP_SESSION_NONE) session_start(); $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; $_SESSION['uid'] = $user['uid']; $_SESSION['role'] = $user['role']; header('Location: /'); exit; } } else { $error = 'Invalid account or password'; } } } include __DIR__ . '/../includes/header.php'; ?>
BYRO