Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

url redirection 1

Status
Not open for further replies.

Haraldo

Programmer
Jun 9, 2003
41
GB
I have been looking for a while for a way to redirect my page once someone has logged in.

I have beed trying to use the following:

header ( "Location: etc ");
exit;

but i always get the error that the headers have already been sent:

Warning: Cannot add header information - headers already sent by (output started at etc

Is there another way,

Thanks H
 
The error you're getting is due to the way the HTTP protocol is designed to carry HTML pages.

A web-server's HTTP response to a page request consists of three parts: as status line, a set of one or more HTTP response headers, and the content of the page requested.

The response header section and the content section are separated by a blank line. When a PHP script instructs it to output something, PHP assumes that all headers have been sent, so it sends that blank line. If you then attempt to do something that requires additional headers to be sent, PHP correctly barfs.

There are two workarounds. One is to reorganize your page so that all program logic happens (and all headers are sent) before PHP attempts to output any page content.

The other way is to turn on output buffering, which is described in: I recommend that you not use this unless necessary, as output buffering can cause an increased load on your server.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks for the advice, much appreciated...
H
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top