我有一个网站,我想限制用户在重置密码时不应使用之前的3个密码作为新密码。
答案 0 :(得分:0)
将以前的哈希密码保存在数据库中,并在创建新密码时检查它是否与以前的密码不匹配。
答案 1 :(得分:0)
将以前的密码存储在数据库中。 old_pass_1,old_pass_2和old_pass_3。
submits password for update
check if new password matches with any of the field old_pass_1, old_pass_2 or old_pass_3. If not then proceed else go to %
check if old_pass_1 is empty - store old pass here and go to #
else check if old_pass_2 is empty - yes - move old_pass_1 to old_pass_2 and update old_pass_1 with old password and go to #
else check if old_pass_3 is empty - yes - move old_pass_2 to old_pass_3 and old_pass_1 to old_pass_2 and store the old pass to old_pass_1
else if none of them is empty then move move old_pass_2 to old_pass_3 and old_pass_1 to old_pass_2 and store the old pass to old_pass_1
# store the new password to the password field.
%Display message password was already used earlier by you.
答案 2 :(得分:0)
您已将所有三个密码存储在表格中,如old_password,old_password1,old_password2。 当用户请求更改密码时,从表中获取所有三个密码 如果当前密码不等于最后三个,则比较它们然后更新。 我会更喜欢使用switch case而不是if else log。
$a='old_password1';
$b='old_password2';
$c='old_password3';
$pass ='new password ';
switch ($pass){
case $a:
echo "nope1";
break;
case $b:
echo "nope2";
break;
case $c:
echo "nope3";
break;
default :
echo "update password here";
}
性能明智的开关案例比其他许多链条更好 希望它会对你有所帮助。快乐的编码。