So… if you have a script that states something like so…
while($result = mysql_fetch_array($resource))
{
if($result['TITLE'] == $this->title)
{
header("LOCATION: profile.php?error=11");
}
echo 'testing';
}
//Create the database profile
$second_query = "INSERT INTO profiles(USER_ID, KEYWORDS, TITLE, INTRO) ";
$second_query .= "VALUES(".$this->userId.",'".serialize($this->keywords)."','".$this->title."','".$this->intro."')";
echo $second_query;
if($result = mysql_query($second_query))
{
if(isset($file))
{
$this->update_profile($this->files);
}
return true;
}else
{
return false;
}
and the first condition fails and sends the header back… If you don’t return false after sending the header, does it continue running the script? I had an issue to where if the title was found in my database it would return the error, but it would continue running that script, thus inserting a duplicate title entry into my database.
So again… does a script continue executing even after you send a header? aka (in this case) a redirect?
If a
locationheader is sent without anexityes it continues to run script.Valid:
Think about that
headerisn’t executed by the PHP itself, it’s executed by the browser, same thing when you apply aheader("Content-Type: application/force-download");it tells the browser that the following outputted block has to be downloaded.So even if you set the header to another location, all code inside script, unless we exit, gets processed by
PHPand then the browser gets the location and redirects.