After login, header() redirect does not work in PHP.

After login, header() redirect does not work in PHP.

Redirects fail if output is sent before header().
❌ Wrong:
echo "Login successful";
header("Location: dashboard.php");

✅ Correct:
header("Location: dashboard.php");
exit;

Back