Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php redirect



3:38 pm on Aug 21, 2002 (gmt 0)

10+ Year Member

How can you execute a redirect using php from within an HTML document, without using javascript? Is it possible, would you have to put some php command in the <head></head> section? If I try to use header() function, it says error: header has already been sent...


3:42 pm on Aug 21, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Yes, a common newbie error.

You must send any headers including calls to session_start() session_register() and set_cookie before you send any other headers, like this:

if(!$username) {
header("Location: /login.php");
etc etc....



3:54 pm on Aug 21, 2002 (gmt 0)

10+ Year Member

I always insist to place
right after the
header("location: url.html");

Featured Threads

Hot Threads This Week

Hot Threads This Month