Re: simplest user-auth possible...
| From: | Chris Lee | Date: | Wed, 06 Dec 2000 02:58:30 +0000 |
| Subject: | Re: simplest user-auth possible... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28815@lists.php.net to get a copy of this message | ||
If you only have three passwords, split the site over three dir's and use
htpasswd for the fastest solution, if you want great expandability use
php.
<?
function bad_passwd()
{
echo "Bad Passwd<br>\n";
exit();
}
if ( !isset($PHP_AUTH_USER) OR !isset($PHP_AUTH_PW) OR !($people =
fetch_db_value("people", "WHERE username = '$PHP_AUTH_USER' AND passwd =
'$PHP_AUTH_PW' ")) )
{
Header("WWW-Authenticate: Basic realm='$SERVER_NAME' ");
Header("HTTP/1.0 401 Unauthorized");
bad_passwd();
}
echo "your in the site :) <br>\n";
?>
where fetch_db_value() is your db function.
more info at
http://php.net/manual/features.http-auth.php
You will find with more reading that there are strange things people have
found when using IE, Netscape, Amaya, etc. etc regarding to order of
those two header() 's
Chris Lee
Mediawaveonline.com
In article <5.0.0.25.2.20001205231254.024332b0@pop-gw.vento.com.br>,
"Christian Dechery" <lemming@vento.com.br> wrote:
> I'm trying to make an internal weblike BBS for my company... and I'd
> like to use PHP...
>
> It would be divided in three sections and the 'users' would only have
> authorization to post on their specific section, but read all... and I
> of course would be able to do whatever I want...
>
> so I'd like to know the simplest way to do user-authorization here...
>
> I know nothing about cookies and sessions... and that's exactly why I'm
> doing this BBS, to learn.
>
> when a user logs on... and he posts something... the posted message will
> have his username, date, and blabla... I don't really wanna control his
> presence on the BBS... just authorize and control who sent the message
> in what section... and also control if he had the privileges for it...
>
> it's really simple... I just need a very basic example...
>
> thanks in advance...
> ____________________________
> . Christian Dechery (lemming)
> . http://www.tanamesa.com.br
> . Gaita-L Owner / Web Developer
>
>
>