prepare('SELECT * FROM users WHERE username = :u'); $stmt->execute([':u' => $username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password_hash'])) { $_SESSION['uid'] = (int)$user['id']; header('Location: index.php'); exit; } flash('error', '用户名或密码错误'); header('Location: index.php?action=login'); exit; } $flash = getFlash(); $loginErr = $flash && ($flash['type'] ?? '') === 'error'; ?>