if ($num_rows == 0 && $num_rows2 == 0) {
echo 'result1';
header('Location:enter-work.php');
die();
} else if ($num_rows >= 0 || $num_rows2 >= 0) {
echo 'result2';
header('Location:similar-work.php');
die();
}
I have the above code that I’m testing with and it properly echos out the sample text ‘result1’ or ‘result2’ every single time I refresh the page with this code, but it is not redirecting to enter-work.php or similar-work.php like it does on my localhost server. On my localhost server, I can even link it to online websites (ie. google.com). And I inputed the above code before any html was written – so before even the doctype was declared.
Not sure what’s causing the problem, need some help.
EDIT: as Pekka mentioned in his comments (on the selected answer) the problem was I had echos and white spaces before the header() function.
You mustn’t output any content before sending headers.
That the local and live server behave differently if you do, may be because of different output buffering settings.
Anyway, it should work if you remove the echos.