HTML tags in auth.php script
| From: | narendra dot talele at us dot abb dot com | Date: | Fri, 10 Jan 2003 20:12:58 +0000 |
| Subject: | HTML tags in auth.php script | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24763@lists.php.net to get a copy of this message | ||
PHP 4.2.3
APACHE 1.3.27
Windows 2K
Hello every one. I am still learning how PHP works. Can some one answer
this
for me please.
This piece of code here works fine ONLY without the HTML tags (The
first line and the last lines in the code).
The moment I add these lines I get the following error: (By the way I
don't get these errors if I execute this script on UNIX)
Warning: Cannot add header information - headers already sent by (output
started at c:\phpdev\www\public\auth.php:2) in
c:\phpdev\www\public\auth.php on line 4
Warning: Cannot add header information - headers already sent by
(output started at c:\phpdev\www\public\auth.php:2) in
c:\phpdev\www\public\auth.php on line 5
Text to send if user hits Cancel button
Basically what I am trying to do is to add
this line to get a background image for this page "auth.php" in my
images folder.
<body background=\"../pics/creme_swirl.jpg\" text=\"green\"
link=\"blue\" alink=\"red\" vlink=\"red\">
<HTML>
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your
password.</p>";
}
?>
</HTML>