<?php
if (empty($PHP_AUTH_USER) || empty($PHP_AUTH_PW)) {
    header( 'WWW-Authenticate: Basic realm="Private"' );
    header( 'HTTP/1.0 401 Unauthorized' );
    echo 'Authorization Required.';
    exit;
} else {
    echo "You entered $PHP_AUTH_USER for a username.<BR>";
    echo "You entered $PHP_AUTH_PW for a password.<BR>";
}
?>

-----Original Message-----
From: morten [mailto:[EMAIL PROTECTED]]
Sent: 12 November 2001 17:13
To: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] $PHP_AUTH_USER


Hi,

Yes the first one worked, but now I'm having trouble withe this one.
How come? All these headers and $ have been a bit buggy...

<?php
if ((!isset( $PHP_AUTH_USER )) || (!isset($PHP_AUTH_PW))) {
    header( 'WWW-Authenticate: Basic realm="Private"' );
    header( 'HTTP/1.0 401 Unauthorized' );
    echo 'Authorization Required.';
    exit;
} else {
    echo "You entered $PHP_AUTH_USER for a username.<BR>";
    echo "You entered $PHP_AUTH_PW for a password.<BR>";
}
?>

Morten

"Morten" <[EMAIL PROTECTED]> skrev i en meddelelse
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi Ross,
>
> Thanks a LOT. It worked when I shifted to the LoadModule script.
>
> In all the danish sites where they wrote about php/apache they use the old
> script. How come if it is not working with headers?
>
> Morten
>
> "Ross Fleming" <[EMAIL PROTECTED]> skrev i en meddelelse
> news:[EMAIL PROTECTED]...
> > You haven't installed it as an apache module.  I double checked.  To see
> if
> > I'm right, just create a php script with this in it:
> > <?
> > getallheaders();
> > ?>
> >
> > If it says "call to undefined function" when u view it in explorer then
do
> > the following.
> >
> > Copy php4ts.dll to windows/system or winnt/system32 or whatever one is
> > applicable.
> >
> > Edit your httpd.conf and delete:
> >    ScriptAlias /php/ "c:/php/"
> >    AddType application/x-httpd-php .php
> >    Action application/x-httpd-php "/php/php.exe"
> > wherever it might be and type this in its place:
> >
> >    LoadModule php4_module c:/php/sapi/php4apache.dll
> >    AddType application/x-httpd-php .php
> >
> > making sure of course, that c:/php is where you've got php installed.
> >
> > Restart apache and hey presto..
> >
> > Ross
> >
> > -----Original Message-----
> > From: Ross Fleming [mailto:[EMAIL PROTECTED]]
> > Sent: 11 November 2001 22:14
> > To: Morten [Achtung]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: RE: [PHP-WIN] $PHP_AUTH_USER
> >
> >
> > OK, having run the same script, I'm getting a 500 as well, still not
sure
> > why, but I know the cause.  Take out
> >     header("HTTP/1.0 401 Unauthorized");
> > and it works.  I really don't know why this doesn't work though, so
> anyone,
> > know why
> >
> > header("HTTP/1.0 401 Unauthorised");  causes an internal server error?..
> >
> >
> > Ross
> >
> > -----Original Message-----
> > From: Morten [Achtung] [mailto:[EMAIL PROTECTED]]
> > Sent: 11 November 2001 17:35
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: SV: [PHP-WIN] $PHP_AUTH_USER
> >
> >
> > I am not running it as a CGI script.
> > It's install on my computer together with Apache.
> >
> > I tried several script's but the don't work. Do I have to work
> > with the php.ini file or?
> >
> > Morten
> >
> > -----Oprindelig meddelelse-----
> > Fra: Ross Fleming [mailto:[EMAIL PROTECTED]]
> > Sendt: 11. november 2001 17:24
> > Til: morten; [EMAIL PROTECTED]
> > Emne: RE: [PHP-WIN] $PHP_AUTH_USER
> >
> >
> > How are you using PHP with the webserver?  If you're running it as a CGI
> > script then you can't access those variables
> >
> > Ross
> >
> > -----Original Message-----
> > From: morten [mailto:[EMAIL PROTECTED]]
> > Sent: 11 November 2001 14:55
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-WIN] $PHP_AUTH_USER
> >
> >
> > Hi,
> >
> > I am trying to find out how to use $PHP_AUTH_USER. The problem is
> > that I don't progress because of an 'Internal Server Error'. I tried
> > this
> > script
> > from php.net:
> >
> > <?php
> >   if(!isset($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\n";
> >     exit;
> >   } else {
> >     echo "<p>Hello $PHP_AUTH_USER.</p>";
> >     echo "<p>You entered $PHP_AUTH_PW as your password.</p>";
> >   }
> > ?>
> >
> > But the only answer is this: Internal Server Error. Is it the php.ini
> > file
> > that's not
> > configured well, or..?
> >
> > Morten
> >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
>



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to