这段代码有问题吗?当otp!= rand时,页面往往显示echo "<script>alert('Too many failures. Please login again.'); location.href='login.php';</script>";
即使尝试&lt; 3.我该如何解决这个问题? :(
if ($otp == $rand) {
//$query = "SELECT * FROM user WHERE user_id='$user_id' AND otp='$otp'";
//$result = mysqli_query($link, $query) or die(mysqli_error($link));
echo "<script>location.href='viewAccountBalance.php'</script>";
}
else if ($otp != $rand) {
$_SESSION['attempts']++;
if ($_SESSION['attempts'] < 3){
echo "<script>alert('You have keyed in an invalid iBanking OTP. Please try again.');location.href='loginOtp.php'</script>";
}
else{
echo "<script>alert('Too many failures. Please login again.'); location.href='login.php';</script>";
}
}
}
答案 0 :(得分:0)
试试这个,
$_SESSION['attempts'] = $_SESSION['attempts']+1;
答案 1 :(得分:0)
这也发生在我身上。我不知道会发生这种情况,但这对我有用
$_SESSION['attempts']++;
到
$_SESSION['attempts'] = $_SESSION['attempts'] + 1;