本文整理汇总了PHP中security::hash方法的典型用法代码示例。如果您正苦于以下问题:PHP security::hash方法的具体用法?PHP security::hash怎么用?PHP security::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类security
的用法示例。
在下文中一共展示了security::hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
include_once "info/info.php";
include_once "classes/class_base.php";
include_once "classes/class_security.php";
$connect = Base::getDB($host, $user, $pass);
// проверка наличия пароля и логина в базе даннызх
if (isset($_POST['login']) && isset($_POST['password'])) {
$login = $_POST['login'];
$password = $_POST['password'];
$hash_password = security::hash($password, $salt);
$query = "SELECT * FROM users WHERE login = '{$login}' AND password = '{$hash_password}'";
$autorization = $connect->select($query);
if ($autorization) {
echo 'Вы вошли как ' . $autorization['login'];
} else {
return false;
}
}
// регистрация нового пользователя
if (isset($_POST['registration_login']) && isset($_POST['registration_password'])) {
$login = $_POST['registration_login'];
$password = $_POST['registration_password'];
$name = $_POST['registration_name'];
$firstname = $_POST['registration_firstname'];
$email = $_POST['registration_email'];
$hash_password = security::hash($password, $salt);
$registration = $connect->insert($login, $hash_password, $name, $firstname, $email);
if ($registration == 1) {
echo 'Регистрация прошла успешно';
}
}