Another script problem....
I have a very basic auth system I'm using on one page (a blog script I created) which authenticates the user. However, when I try to call the page, instead of prompting for user/pass, I get the following errors:
Warning: Cannot add header information - headers already sent by (output started at c:\ibserver\www\header.php:4) in c:\ibserver\www\addnews.php on line 13
Warning: Cannot add header information - headers already sent by (output started at c:\ibserver\www\header.php:4) in c:\ibserver\www\addnews.php on line 14
Access Denied!
This is my script:
<?php
include "header.php";
include "config.php";
$LOGIN = "$admin";
$PASSWORD = "$adminpass";
function error ($error_message) {
echo $error_message."<BR>";
exit;
}
if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == "$PASSWORD" )) ) {
header("WWW-Authenticate: Basic entry=\"News Blog\"");
header("HTTP/1.0 401 Unauthorized");
error("Access Denied!");
}
?> ...protected page content goes here...
I thought it might be because I am including header.php at the top (which is ony the header inc of all pages - aesthetic only) but removing that then caused the browser to crash (??) instead of the instant error I got above.
Any ideas what I am missing here?
Thanks in advance,
Jonathen