Re: Cannot add header information...

From: Date: Thu, 22 Nov 2001 10:28:49 +0000
Subject: Re: Cannot add header information...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75493@lists.php.net to get a copy of this message
Per, Its a hard rule but you cannot sent any HTML content before the header. Try reversing the order and see if that works. George (a newbie, trying to find time to learn more) ----- Original Message ----- From: "Per Waagen" <dataper@online.no> To: <php-general@lists.php.net> Sent: Thursday, November 22, 2001 10:19 AM Subject: [PHP] Cannot add header information... > Need some help here, Im getting this error: > > Warning: Cannot add header information - headers already sent by (output > started at /home/p/pe/perphp/public_html/login.php:4) in > /home/p/pe/perphp/public_html/login.php on line 44 > > ...while trying to run the following .PHP code on my server. Any ideas why > this doesnt work? > (Im trying to setup user authentication and found this on the Webmonkey > site) > > All tips are appreciated!! > > > <HTML><HEAD><TITLE>dummy</TITLE></HEAD> > <BODY> > > <?php > > // File Name: auth02.php > // Check to see if $PHP_AUTH_USER already contains info > > if (!isset($PHP_AUTH_USER)) { > // If empty, send header causing dialog box to appear > header('WWW-Authenticate: Basic realm="My Private Stuff"'); > header('HTTP/1.0 401 Unauthorized'); > echo 'Authorization Required.'; > exit; > } else if (isset($PHP_AUTH_USER)) { > > if (($PHP_AUTH_USER != "admin") || ($PHP_AUTH_PW != "abc123")) { > header('WWW-Authenticate: Basic realm="My Private Stuff"'); > header('HTTP/1.0 401 Unauthorized'); > echo 'Authorization Required.'; > exit; > > } else { > echo " > <P>You're authorized!</p> > "; > } > } > ?> > </BODY> > </HTML> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.general (#75493) next »