本文整理汇总了PHP中Password::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::set方法的具体用法?PHP Password::set怎么用?PHP Password::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Password
的用法示例。
在下文中一共展示了Password::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setpw
function setpw() {
try {
$P = new Password();
$pass_exists = $P->exists();
} catch(Exception $e) {
die($e->getMessage());
}
if($_POST['newpass']) {
if($pass_exists && !$P->isValid($_POST['password'])) {
$pass_incorrect = true;
} else {
$confirm_failed = $_POST['newpass'] != $_POST['passconfirm'];
// (Try to) set the password
if(!$confirm_failed) {
try {
$set_pass = $P->set($_POST['newpass'], $db);
} catch(Exception $e) {
die($e->getMessage());
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head><title>set scraps password</title></head>
<body>
<?php if($pass_incorrect): ?>
<p>The password entered does not match the current password.</p>
<?php elseif($set_pass): ?>
<p>Password set successfully.</p>
<?php else: ?>
<?php if($confirm_failed): ?>
<p>The passwords you entered don't match.</p>
<?php endif; ?>
<form method="post">
<?php if($pass_exists): ?>
<input name="password" type="password" placeholder="Current password?" \>
<?php endif; ?>
<input name="newpass" type="password" placeholder="New password"\>
<input name="passconfirm" type="password" placeholder="Confirm new password" \>
<input type="submit" value="Set Password" />
</form>
</body>
</html>
<?php endif;
}