Go to a page with php

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
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Go to a page with php

Post by Sindarin »

Is there any other way except echoing meta refresh tags and header to direct the user to another page from a php script?
server-side is always preferred.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Go to a page with php

Post by Zoxive »

Code: Select all

header("Location: http://www.mysite.com/mypage.php");
What's wrong with header? That is server side.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Go to a page with php

Post by Sindarin »

My server outputs a 500 server error, whenever I try to use it for files that are on the server (index.html) but not for external links (e.g. http://www.google.com).
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Go to a page with php

Post by Zoxive »

You need to use full paths. Like my example.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Go to a page with php

Post by Jonah Bron »

Also, I think this works...

Code: Select all

header('REFRESH', '0;URL=http://someaddress.com/some_file');
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Go to a page with php

Post by Chris Corbyn »

PHPyoungster wrote:Also, I think this works...

Code: Select all

header('REFRESH', '0;URL=http://someaddress.com/some_file');
No it won't. Header sends a HTTP header and it's just the first argument which contains the string. The second is a boolean.

http://au2.php.net/header
Post Reply