Originally posted by leatherback
Hi,
-> you do not need the exit after the redirect, since the page will not be loaded any further
Not strictly true, the header command just set's info to the http header. everything else is still run but the user doesn't see this because he is redirected as soon as the http message starts on the body. The script does continue to run on the server though. Try the following as a little experiment.
<?php
$fp=fopen('./afile.dat','w+');
for($i=0;$i<10;$i++) {
fwrite($fp, "$i\n");
}
header('Location: [url]http://www.google.com[/url]');
for(;$i<20;$i++) {
fwrite($fp, "$i\n");
}
echo('blah'); //Start the http body
for(;$i<30;$i++) {
fwrite($fp, "$i\n");
}
?>
Usually the only issue is that you have code being run unnecessarily on your server. However consider the following.
if($condition==true) {
header('Location: page1.php');
}
header('Location: page2.php');
Where would you be redirected to if $condition where true? The answer is, you'd still be redirected to page2.php because that will be the last Location header that the browser sees.
I only found all this out last week to be honest (doing some load balancing stuff accross our servers).
HTH
Bubble
[edit]Typos[/edit]