prepare('SELECT * FROM admins WHERE account = ? AND password = SHA2(?, 256)'); $stmt->execute([trim($_POST['account'] ?? ''), $_POST['password'] ?? '']); if ($admin = $stmt->fetch()) { session_regenerate_id(true); $_SESSION['admin_id'] = $admin['id']; $_SESSION['admin_account'] = $admin['account']; header('Location: index.php'); exit; } $error = '帳號或密碼錯誤'; } ?> 後台登入

THREE WORDS · ADMIN

舞台資料管理

乙級練習:Session 登入與資料庫驗證