prepare('SELECT * FROM public.admin_users WHERE email = ?'); $stmt->execute([$email]); $user = $stmt->fetch(PDO::FETCH_ASSOC); // IMPORTANT: PHP's password_verify function is the correct way to check a bcrypt hash. if ($user && password_verify($password, $user['password'])) { // Password is correct, so start a new session $_SESSION['user_id'] = $user['id']; $_SESSION['user_email'] = $user['email']; $_SESSION['user_fullname'] = $user['full_name']; // Redirect to a protected admin page header("Location: admin_dashboard.php"); exit; } else { // Invalid credentials $error_message = 'Invalid email or password.'; } } catch (PDOException $e) { // In a real app, you would log this error, not show it to the user. $error_message = 'Database error. Please try again later.'; // error_log($e->getMessage()); } } } ?> Admin Login

Admin Login