Re: Validation: Problems with header(Location) in PHP

From: Date: Tue, 23 Sep 2003 23:20:19 +0000
Subject: Re: Validation: Problems with header(Location) in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-163653@lists.php.net to get a copy of this message
HTTP 1.1 says the following: 1. Client (with web browser) sends GET request to server. 2. Server responds with something like: Content-type: text/html Content-size:...blah...blah...blah.... 3. Server sends the web page. The header is sent on #2. What is happening is that somewhere in the code you are outputting the HTML. So PHP reads: 1. Client (with web browser) sends GET request to server. 2. Server responds with something like: Content-type: text/html Content-size:...blah...blah...blah.... 3. Server sends the web page. 4. Server responds with something like: Redirect (or whatever it is) Content-type: text/html Content-size:...blah...blah...blah.... But because step 2 (which is also step 4) can only happen once, PHP outputs an error. You need to locate the snippet of code outputting anything first, and disable it. Of course, I will not get into whether or not hiding headers from the user is a good idea. (In some forms of CGI scripting you would actually have to type: print "Content-type: text/html\n\n" before doing anything else.) -Dan

« previous php.general (#163653) next »