我有两个名为 security_questions 和 login 的表。登录表中的列是:
Username, Security_QA_ID, Security_Answer, Security_Attempts,Last_Login,Password_Attempts
其中 security_questions 有:
ID, Name
其中 Security_QA_ID 用 ID 引用
CREATE DEFINER=`satish`@`%` PROCEDURE `p_chkAnswer`(
IN sq VARCHAR(75),
IN sa VARCHAR(20) ,
IN uname VARCHAR(15) ,
out msg INT
)
BEGIN
select (COUNT(*) > 0) INTO @result from login join security_questions on Security_QA_ID = ID where User_Name=uname and Name=sq and Security_Answer=sa;
set msg = @result;
if @result = 1 Then
UPDATE login SET Last_Login=now(),Password_Attempts=0 where User_Name=uname;
else
UPDATE login SET Security_Attempts=Security_Attempts+1 where User_Name=uname;
End if;
END
但在每次只有 else 部分执行。提前致谢