用这个函数代替Request,可以防止SQL注入.
Function SafeRequest(ParaName,ParaType)
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)
Dim Paravalue
Paravalue=Request(ParaName)
If ParaType=1 then
If not isNumeric(Paravalue) then
Response.write "参数" & ParaName & "必须为数字型!"
Response.end
End if
Else
Paravalue=replace(Paravalue,"'","''")
End if
SafeRequest=Paravalue
End function
博客介绍了一个可代替Request以防止SQL注入的函数SafeRequest。该函数接收参数名称和参数类型,参数类型为数字型,1表示数字,0表示字符。函数会根据参数类型对参数值进行处理,若为数字会检查是否为数字型,若为字符会替换单引号。
1749

被折叠的 条评论
为什么被折叠?



