Re: header information problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






Ahmed Abdel-Aliem wrote:
> Dear Groups members.
>
> i am making a user protected page, the script works excellent on my
> local server, but online it gives me this error :

Your local server has output_buffering turned ON in php.ini

Your online server does not.

> Warning: Cannot modify header information - headers already sent by
> (output started at
> /home/me2resh/public_html/apex/upload/header.html:10) in
> /home/me2resh/public_html/apex/upload/upload.php on line 33
.
.
.
> 	include 'header.html';
.
.
.
>         header("Location: login_success.php");

First of all, you CANNOT do "header" once PHP has started sending
HTML/content to the browser.

Think (or learn) about how HTTP headers and content works, and it will be
obvious why.

Secondly, header("Location: ...") is BAD PROGRAMMING!

The Location: header is part of the HTTP protocol to inform browsers when
a document has *MOVED*.

You have *not* moved your login script, nor your success page, nor any
other on-line document.

You are using (abusing) the Location: header as if it were a PHP
programming construct such as 'if/else/while/include/echo/...' which it is
not.

Don't do that.

You would be MUCH better off to just:
include 'login_success.php';
here.

You might need to re-structure a few things in your code, but it will be
much cleaner in the end.

In the short run, you can just turn on output buffering on your online
server, and it will "work"  --  In the long run, your code will be
difficult to maintain, impossible to debug, and have weird logic until you
re-structure it to deal with any kind of 'headers' first, then use include
to pull in the correct html/php, and never, ever, ever, use
header("Location: ") for anything except a document that has moved from
one URL to another.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux