You are here: Re: Password Protection « PHP « IT news, forums, messages
Re: Password Protection

Posted by Steve on 02/17/05 10:03

Kevin Javia wrote:
> I am experimenting on my site and I want to make it password protected like
> www.realsolution.com.
>
> If any one enters correct user name and password, only then they will be
> able to enter into my site.
>
> How can I do that in PHP?
>
> Any ideas? Thanks a ton in advance.


Try this:



function authenticate() {
header('WWW-authenticate: basic realm="My protected area"');
header('HTTP/1.0 401 Unauthorized');
print 'Please use a correct login!';
exit;
}


function authorize() {
if( (!isset($_SERVER['PHP_AUTH_USER']))
or ($_SERVER['PHP_AUTH_USER'] == '') ) {
authenticate();
}
else {
$login = strtolower($_SERVER['PHP_AUTH_USER']);
$passwd = $_SERVER['PHP_AUTH_PW'];

if (.....) { // check $login and $passwd against the list of
authorized users
return true;
}
else {
authenticate();
}
}
return false;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация