I am following along with a Lynda.com tutorial on php and am learning about php redirects. Using header("Location: basic.html"), the tutor says for a redirect to work it must be the very first thing on a page. However, I tested that by putting the php code within the tags and the redirect still worked. I have looked at other online resources and they too say that there should be nothing above the redirect. Are the resources I have looked at simply out of date or am I missing a point here?
Thanks
I am running XAMPP on my local machine. My code is:
Redirect
<?php
// This is how you redirect to a new page
function redirect_to($new_location) {
header("Location: " . $new_location);
exit;
}
$logged_in = $_GET['logged_in'];
if($logged_in == 1) {
redirect_to("basic.html");
} else {
redirect_to("http://www.google.co.uk");
}
?>
</body>