Redirect not working

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
Jhorra
Forum Newbie
Posts: 24
Joined: Mon Aug 18, 2003 1:00 am

Redirect not working

Post by Jhorra »

I have a page that redirects at the end. For some reason on this single page it doesn't redirect. I've tried a hundred different things, it just goes to a blank page. If you look at the source code for the page it's completely blank. If I echo out the location of the redirect right before the line that redirects, it shows correctly. Also, it seems that it was working yesterday, and as far as I know there have been no changes to the page since then.
Jhorra
Forum Newbie
Posts: 24
Joined: Mon Aug 18, 2003 1:00 am

Post by Jhorra »

Additional info:

The way it currently works is this:

The end of the page shows this: show_screen($location);

This is that function:

Code: Select all

function show_screen($loc){
Header("Location: $loc");
exit;
}
I echo out the $location before it calls the function, and it works fine. I echo $loc inside the function and it's blank. If I bypass the function completely and just put in a header("Location: url.php") it doesn't redirect.
tapas_bahirbag
Forum Newbie
Posts: 14
Joined: Sun Aug 06, 2006 6:54 am
Contact:

Post by tapas_bahirbag »

You can try this:

Code: Select all

function show_screen($loc){
ob_end_flush();
Header("Location: $loc");
exit;
}
--
Tapos Pal
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

Check if headers are sent.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

Gente wrote:Check if headers are sent.
Or are enabled by the hosting company also if that are any changes to the location of the file or typo on your part.
Post Reply