php forwarding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
byenary
Forum Newbie
Posts: 10
Joined: Mon Apr 03, 2006 6:15 am

php forwarding

Post 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 ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply