Skip to content

Instantly share code, notes, and snippets.

@zafe
Last active August 29, 2015 14:11
Show Gist options
  • Save zafe/f5c64d0d85e3351afbd8 to your computer and use it in GitHub Desktop.
Save zafe/f5c64d0d85e3351afbd8 to your computer and use it in GitHub Desktop.
Login with PHP using crypt()
<?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