homepage Welcome to WebmasterWorld Guest from 54.197.111.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php redirect
scorpion




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

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

 

Nick_W




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

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");
}
?>
<html>
etc etc....

Nick

transistor




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

I always insist to place
exit; right after the header("location: url.html");.
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved