Tags
Asked 3 years ago
13 Jul 2021
Views 158
Jayson

Jayson posted

Why header location is not working in PHP ?


header("location:index.php");



Why header location is not working in PHP ?
sachin

sachin
answered Jul 18 '21 00:00

as per code

header("location:index.php");

it should work usually but you did not give proper error what you getting .
but following the possible reason :
1.sent header by putting HTML before the header function
2. use of session_start(); before header location
3. use of cookie function like set_cookie also send header again
4. some time simple white space also send a header


<?php 
header("location:index.php");
?>

method
so avoid above all header already sent
Post Answer