Ok, this is the script, it's pretty much self-explanatory:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php
function startPage() {
print ("\n");
print ("<head>\n");
print ("<title>My page</title>\n");
print ("</head>\n");
print ("<body>\n");
}
function endPage() {
print ("</body>\n");
print ("\n");
}
if (($PHP_AUTH_USER =="username") && ($PHP_AUTH_PW == "secret")) {
startPage();
print ("You have logged in successfully!<br>\n");
endPage();
} else {
header ("WWW-Authenticate: Basic realm=\"Leon's Protected Area\"");
header ("HTTP/1.0 401 Unauthorized");
print ("This page is protected by HTTP Authentication. <br>\n");
print ("Use <b>leon</b> for the username, and <b>secret</b> ");
print ("for the password.<br>\n");
}
?>
Now this is the error I get:
Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\authentication.php3:2) in c:\inetpub\wwwroot\authentication.php3 on line 18
Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\authentication.php3:2) in c:\inetpub\wwwroot\authentication.php3 on line 19
My question is: how should I rearrange this page, making it work?
thx