Jump to content

Does header("Location") Behave Like A die() Statement?


JustinK101

Recommended Posts

We just ran across something very confusing using header("Location"). Does header("Location") work just like a die() statement, in that execution stops? Because we found that execution can continue for a few lines even after hitting the header("Location"). For example, take this:

 

<?php

      if(empty($_POST['username']) || empty($_POST['password'])) {

header("Location: /login");

}

 

        header("Location: /home");

?>

 

When testing, and $_POST['username'] and $_POST['password'] were empty, we were being redirected to /home instead of /login.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.