Last active
August 29, 2015 14:11
-
-
Save zafe/f5c64d0d85e3351afbd8 to your computer and use it in GitHub Desktop.
Login with PHP using crypt()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define($hash_token,"$%&123");//$hash_token is the key to use in crypt() | |
public function crypt_password($password){ | |
return $encripted_password = crypt($password,$hash_token); | |
} | |
public function login($user_name, $dumb_password){ | |
$encripted_password = crypt($dumb_password, $hash_token); | |
$user = this->get_user_by_name($user_name); | |
/*being get_user_by_name a SQL function which queries | |
*SELECT * FROM User WHERE user_name = $user_name | |
*/ | |
if(strcmp($user['password'], $encripted_password,) == 0){ | |
return $user; | |
}else{ | |
return NULL; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment