prepare("SELECT * FROM users WHERE email = ?"); $stmt->execute([$email]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['user_name'] = $user['name']; header('Location: /dashboard.php'); exit; } else { $errors[] = 'Invalid email or password.'; } } $_SESSION['login_errors'] = $errors; header('Location: /index.php#loginModal'); exit; } // This script does not render HTML. It only processes the form. header('Location: /index.php'); exit;