Your theory is wrong.

The correct answer is that somebody turned output_buffering "ON" in
php.ini (or .htaccess) so the output is not really sent until the
script finishes (up to 4096 chars).

On Tue, May 30, 2006 11:08 am, Philip Thompson wrote:
> Hi all.
>
> I have a site where I include pages within pages. Well, for some of
> the pages I want the user to be logged in, while others I don't care.
> I'm doing something that I thought was not allowed by the header()
> function.
>
> <!-- index.php -->
> <html>
> <head>...</head>
> <body>
> <?
> if ($subPage = $_GET['page'])
>    include ("$subPage");
> ?>
> </body>
> </html>
>
>
> <!-- some subpage that requires a login: subpage.php -->
> <?
> if (!$_SESSION["loggedIn"]) {
>    header ("location: login.php");
>    exit;
> } else {
>    ...
> }
> ?>
>
> As you can see, by the time that index.php includes the subpage, it
> has already outputted HTML. According to using the header() function,
> you are not allowed to output any HTML *before* using header().
> However, I am doing this and it is redirecting fine.
>
> I have hypothesized why it is still redirecting appropriately...
> *subpage.php* has not outputted HTML before it does the check, only
> index.php, so it does not fail. Is this correct? Any help is
> appreciated. It appears to work fine, but I don't want to be
> surprised in the future by my application breaking suddenly!! =D
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to