#12002/11/11 17:03:53
下面是我做的一个数据保存连接,问题是我输入相内容的网站用户名称、EMAIL地址和网址,却不能执行检查报错,照样提示注册成功。我改了好多边就是弄不明白哪里有错误,
请高手指点迷津!
<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit
response.buffer=true
%>
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
dim cmdTemp
dim InsertCursor
dim sql
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText.sql = "SELECT * FROM addnew where username='"&username&"' or TxtEmail='"&E_mail&"' or Txthomepage='"&homepage&"'""
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = conn
InsertCursor.Open cmdTemp, , 1, 3
if InsertCursor.eof then
InsertCursor.addnew
InsertCursor("username") =htmlencode2(Request.Form("userName"))
InsertCursor("E_mail") =htmlencode2(Request.Form("TxtEmail"))
InsertCursor("homepage") =htmlencode2(Request.Form("TxtHomepage"))
InsertCursor("leibie") =htmlencode2(Request.Form("leibie"))
InsertCursor("Note") =htmlencode2(Request.Form("note"))
InsertCursor("time") =cstr(now())
InsertCursor.Update
response.redirect("welcome.asp")
end if
response.write "失败,已有注册用户"
InsertCursor.close
conn.close
set InsertCursor=nothing
set conn=nothing
response.end
%>