3 回答
TA贡献1820条经验 获得超10个赞
我认为您的条件在客户端脚本中是错误的。如果用户名和密码匹配,那么它将返回大于 0 的值。在这种情况下,您的代码应该是
success:function(data)
{
console.log(data);
if(data == 0)
{
$('#availability').html('<span class="text-danger">Username and Password not Match</span>');
$('#register').attr("disabled", true);
}
else
{
$('#availability').html('<span class="text-success">Username and Password Available</span>');
$('#register').attr("disabled", false);
}
}
TA贡献1810条经验 获得超4个赞
你可以试试这个:
if(isset($_POST["username"], $_POST["password"]))
{
$username = $_POST["username"];
$password = $_POST["password"];
$query = mysql_query("SELECT username, password FROM admin WHERE username = '".$username."' AND password = '".$password."'");
$result=$connect->query($query);
if(mysql_num_rows($result) > 0 )
{
$_SESSION["logged_in"] = true;
$_SESSION["username"] = $name;
}
else
{
echo 'The username or password are incorrect!';
}
}
TA贡献1776条经验 获得超12个赞
- 3 回答
- 0 关注
- 205 浏览
添加回答
举报