Zend - The PHP Company




Passwords

Add Code


Password protection  

Type: code fragment
Added by: PhpByBastek
Entered: 24/01/2003
Last modified: 02/12/2002
Rating: - (fewer than 3 votes)
Views: 6333
Password protection based in *.php file


<?
$list 
file("users_list.php");
for (
$index=0$index count($list); $index++)
{
$gr split("|"chop($list[$index]));
$zz explode("||"$list[$index]);


//normal
if($login == $zz[0] && (crypt($password,$password)) == $zz[2] && $zz[0] != "" && $zz[2] != ""){

$spr="ok";
$email=$zz[1];
setcookie("login""$login");
setcookie("password""$password");
}

//admin
if($login == $zz[0] && (crypt($password,$password)) == $zz[2] && $zz[3] == "1" && $zz[0] != "" && $zz[2] != ""){

$admin="yes";
$spr="ok";
setcookie("login""$login");
setcookie("password""$password");
}
}
if(
$spr!="ok"){
exit;
}
?>

password file (users_list.php):

<?
admin
||phpdevil@tlen.pl||deC4b6GnweS0w||1||
normal||phpdevil@tlen.pl||aeCdb6Gnwev0w||0||


(
no "?>" to end)


Usage Example




Rate This Script





Search



This Category All Categories