本文整理汇总了PHP中Hash::hash_password方法的典型用法代码示例。如果您正苦于以下问题:PHP Hash::hash_password方法的具体用法?PHP Hash::hash_password怎么用?PHP Hash::hash_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hash
的用法示例。
在下文中一共展示了Hash::hash_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_user
public function add_user($username, $password, $email)
{
$activate_key = $this->generate_key();
try {
if (!empty($email)) {
$username = Validate::validate_string($username);
$_password = Validate::validate_string($password);
$password = Hash::hash_password($_password);
$email = Validate::validate_email($email);
if (!$this->check_if_registered($email)) {
$sql = "INSERT INTO users(username, password, email, " . "activation) VALUES (?, ?, ?, ?)";
$this->_setSql($sql);
$this->add_record(array($username, $password, $email, $activate_key));
$this->send_activation_email($email, $activate_key);
}
//end of check if registered block
}
// end of if email value empty block
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
//end of try/catch block
}
示例2: create_new_password
public function create_new_password($new_password)
{
Session::clear_error_output();
$password = Hash::hash_password($new_password);
$email = Session::get('email');
$sql = "UPDATE users SET password=? WHERE email = ? " . "LIMIT 1";
Session::clear_error_output();
$this->_setSql($sql);
$this->update_record(array($password, $email));
if ($this->num_rows > 0) {
return TRUE;
} else {
Session::set_error_output('unable to set new password, email address ' . Session::get('email') . ' is not valid');
return FALSE;
}
}