everything executes after a header location!?
Posted: Wed May 18, 2011 5:04 pm
Hi
I've been working on a site for 6 months and have used the header command to redirect loads and loads of times. But i just noticed some crazy behaviour today. Heres a test page:
<?php
include("includes/db_connect.php");
header('location:stores.php');
$sql = "insert into test (id) values (77)";
$result = mysql_query($sql);
?>
when i hit this page, i get redirected to stores.php, but the sql gets executed! Is this supposed to be the behaviour? Have i completely missed the point of header(location:)?? Im baffled as i've used this before, but only now noticed this crazy behaviour!
I've been working on a site for 6 months and have used the header command to redirect loads and loads of times. But i just noticed some crazy behaviour today. Heres a test page:
<?php
include("includes/db_connect.php");
header('location:stores.php');
$sql = "insert into test (id) values (77)";
$result = mysql_query($sql);
?>
when i hit this page, i get redirected to stores.php, but the sql gets executed! Is this supposed to be the behaviour? Have i completely missed the point of header(location:)?? Im baffled as i've used this before, but only now noticed this crazy behaviour!