有谁知道asp里怎么解决 1'or'1'='1可以登入的问题?

来源:百度知道 编辑:UC知道 时间:2024/05/15 04:33:30

不要使用这样的语句"select * from 表名 where UserName='" & 用户名 & "' and Password='" & 密码 & "'"

正确的做法应该是"select * from 表名 where UserName='" & 用户名 & "'"
如果没有此用户,直接退出,如果有此用户,再比较
rs("Password")是否等于密码
正确就登录,不正确就退出

在登陆、注册和修改密码的程序里,在原有的接收密码数据的语句后加入判断,如果包含非法字符则提示错误,示例如下:

<%
password=request("password")
if Check_Str(password) then
%>
<script language=javascript>
alert('包含非法符号!');
history.go(-1);
</script>
<%
else

'你的原有处理语句加在这里

end if

'下面是检查非法字符的函数,可以另存一个文件,在需要用的地方include进来

Function Check_Str(Input)

Output = False
If InStr(Input,Chr(32)) Then Output = True '空格
If InStr(Input,Chr(33)) Then Output = True '!
If InStr(Input,Chr(34)) Then Output = True '"
If InStr(Input,Chr(35)) Then Output = True &