This question already has an answer here: Reference - What does this error mean in PHP? 30 answers How to make a redirect in PHP? 27 answers I'm having issues with my simple PHP script. I want if \$_SESSION['username'] is set to redirect to welcome.php, if not, it goes to /login.php I thought it would be easy but i seem to have some issues. INDEX.php  
 Add exit after you redirect to page whenever you do it with condition. Also write header function as below