gpt4 book ai didi

php - MySQL密码检查器

转载 作者:可可西里 更新时间:2023-10-31 23:07:25 26 4
gpt4 key购买 nike

我的问题:

我有一个密码检查器,可确保密码在插入数据库之前不超过 25 个或 <5 个字符。如果是,它会报错。一切正常,但我似乎无法让它检查密码是否不是 <5 和/或 >25 个字符,然后将其放入数据库。

代码部分:

if (strlen($pswd)>30) {
echo "Your password is too long! Password's should be between 5 and 30 characters long!";
}

if (strlen($pswd)<5) {
echo "Your password is too short! Password's should be between 5 and 30 characters long!";
}

else if (!strlen($pswd)>30||strlen($pswd)<5)
{
$query = mysql_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0')");
die("<h2>Welcome to M8Ster</h2>Please login to your account to get started ...");
}

最佳答案

尝试将所有 if 语句组合成一个 if-elseif-else:

if (strlen($pswd)>30) {
echo "Your password is too long! Password's should be between 5 and 30 characters long!";
} else if (strlen($pswd)<5) {
echo "Your password is too short! Password's should be between 5 and 30 characters long!";
} else {
$query = mysql_query("INSERT INTO users VALUES ('','$un','$fn','$ln','$em','$pswd','$d','0')");
die("<h2>Welcome to M8Ster</h2>Please login to your account to get started ...");
}

关于php - MySQL密码检查器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13783026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com