Page 1 of 1

php forwarding

Posted: Mon Apr 03, 2006 9:55 am
by byenary
Hello,

I'm updating an existing application which contains a lot of scripts to do forwording to other pages,
like this for example

}else{
echo "<script>window.location=\"login.php\"</script>";


Do we have a clean php solution for this matter, cause this is not a very beatifull solution.. or is this the way to do it ?

Posted: Mon Apr 03, 2006 9:58 am
by feyd
If the forward is done in the middle of a page and for whatever reason can't be calculated before output starts, that's the way to do it. However, all the logic should be done prior to any output starting in an ideal world.

Using header('Location: someFullURL') in combination with outputting a <meta> redirection tag (and a brief description of what's happening) in case the users' browser doesn't support header level redirection is the preferred and recommended solution.