ASP判断用户名是否不存在
以下是POST代码<%SetRs=Server.CreateObject("ADODB.Recordset")Sql="select*fromsjmx"Rs.OpenSq...
以下是POST代码
<% Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
Rs.AddNew
rs("shangjia")=request.form("shangjia")
rs("kahao")=request.form("kahao")
rs("hh1")=request.form("hh1")
rs("jinge")=request.form("jinge")
rs("bz")=request.form("bz")
rs("hh2")=request.form("hh2")
rs("hh5")=request.form("hh5")
rs("jifen")= request.form("hh2") * request.form("jinge")
rs("time")=now()
Rs.Update
Rs.Close
Set Rs=Nothing
conn.close
set conn=nothing
response.Write("<script>alert('添加成功');location.href='jydj.asp';</script>")
%>
我要在提交的时候检查 提交的内容在kahao这里面是否存在。如果不存在就返回去重填,如果存在就执行下面的数据就可以了。 展开
<% Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
Rs.AddNew
rs("shangjia")=request.form("shangjia")
rs("kahao")=request.form("kahao")
rs("hh1")=request.form("hh1")
rs("jinge")=request.form("jinge")
rs("bz")=request.form("bz")
rs("hh2")=request.form("hh2")
rs("hh5")=request.form("hh5")
rs("jifen")= request.form("hh2") * request.form("jinge")
rs("time")=now()
Rs.Update
Rs.Close
Set Rs=Nothing
conn.close
set conn=nothing
response.Write("<script>alert('添加成功');location.href='jydj.asp';</script>")
%>
我要在提交的时候检查 提交的内容在kahao这里面是否存在。如果不存在就返回去重填,如果存在就执行下面的数据就可以了。 展开
3个回答
展开全部
Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "select * from sjmx where kahao='"&request.form("kahao")&"'"
if not rs.eof and not rs.bof then
response.Write "<script language='javascript'>alert('内容存在!');history.go(-1);</script>"
else
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
.......
response.Write("<script>alert('添加成功');location.href='jydj.asp';</script>")
end if
Sql = "select * from sjmx where kahao='"&request.form("kahao")&"'"
if not rs.eof and not rs.bof then
response.Write "<script language='javascript'>alert('内容存在!');history.go(-1);</script>"
else
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
.......
response.Write("<script>alert('添加成功');location.href='jydj.asp';</script>")
end if
追问
if not rs.eof and not rs.bof then
对像被关闭时不能操作。
在下面加一句
Rs.Open Sql,conn,1,3
然后还是出错。
对象打开时,不允许操作。
\user\jytj.asp, line 27
Rs.Open Sql,conn,1,3 27行 删除这一行
当前记.........锁定类型的限制。
我扣扣是348840692 好心人帮忙啊。
追答
Rs.Open Sql,conn,1,1
if not rs.eof and not rs.bof then
是少了一句
展开全部
<% Set Rs = Server.CreateObject("ADODB.Recordset")
Sql = "select * from sjmx where shangjia='"&request.form("shangjia")&"'"
rs.open sql,conn,1,1
if not rs.eof then
response.write "此商家已经存在"
response.end
end if
rs.close
'以下是你的代码
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
Rs.AddNew
……
Sql = "select * from sjmx where shangjia='"&request.form("shangjia")&"'"
rs.open sql,conn,1,1
if not rs.eof then
response.write "此商家已经存在"
response.end
end if
rs.close
'以下是你的代码
Sql = "select * from sjmx "
Rs.Open Sql,conn,1,3
Rs.AddNew
……
更多追问追答
追问
你好,谢谢你的回答,
我是要判断kahao 提交的卡号在数据中是否存在,不存在就返回,存在就执行下面的代码。
追答
你改一下就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!-- #include file=../inc/conn.asp -->
<!-- #include file="../inc/Conf.asp" -->
<!-- #include file="../inc/MD5.asp" -->
<%
'on error resume next
'服务端密码解密
Dim GetCheckCode
GetCheckCode = trim(Session("CheckCode"))
if trim(GetCheckCode)<>trim(request.form("ChkCode")) then
Response.write "<script>"
Response.write "parent.document.getElementById(""Form_GetCode"").focus();"
Response.write "parent.document.getElementById(""errmsg"").innerHTML = '提示信息:验证码错误!';"
Response.write "</script>"
response.end
end if
Dim HiddenPass,PicNum,PassWord,UserName,UserId
HiddenPass = request.form("PwHidden")
PicNum = request.form("PicNum")
PassWord = strDecode(HiddenPass,trim(PicNum))
UserName = trim(request.form("LogName"))
Dim isLogin
SQL = "select UserID,UserName from U_User where LCase(UserName)='"&LCase(UserName)&"' and LCase(UserPass)='"&LCase(MD5(PassWord))&"'"
set Rs = Conn.execute(SQL)
if Rs.eof then
isLogin = False
else
isLogin = True
UserId = Rs("UserID")
UserName = Rs("UserName")
Session("AdminUserID") = UserId
Session("AdminUserName") = UserName
end if
Rs.close
set Rs = nothing
if isLogin then
Response.write "<script>parent.location.href='index.asp';</script>"
else
Response.write "<script>"
Response.write "parent.document.getElementById(""Form_UserName"").focus();"
Response.write "parent.document.getElementById(""errmsg"").innerHTML = '提示信息:用户名/密码错误!请重新输入!';"
Response.write "</script>"
end if
'服务端解密函数
function strDecode(sd_Data, sd_bassnum)
dim sd_vChar
dim sd_NewData
dim sd_TempChar
sd_vChar = 1
do
if sd_vChar > Len(sd_Data) then
exit do
end if
sd_TempChar = CLng(Mid(sd_Data, sd_vChar, 5))
sd_TempChar = ChrW(65535 + sd_bassnum - sd_TempChar)
sd_NewData = sd_NewData & sd_TempChar
sd_vChar = sd_vChar + 5
loop
strDecode = sd_NewData
end function
'异常错误处理
if err.number <> 0 then
logError err.number,forerr(err.source&":"&err.description)
err.clear
Response.end
end if
Conn.Close
set Conn = nothing
%>
<!-- #include file="../inc/Conf.asp" -->
<!-- #include file="../inc/MD5.asp" -->
<%
'on error resume next
'服务端密码解密
Dim GetCheckCode
GetCheckCode = trim(Session("CheckCode"))
if trim(GetCheckCode)<>trim(request.form("ChkCode")) then
Response.write "<script>"
Response.write "parent.document.getElementById(""Form_GetCode"").focus();"
Response.write "parent.document.getElementById(""errmsg"").innerHTML = '提示信息:验证码错误!';"
Response.write "</script>"
response.end
end if
Dim HiddenPass,PicNum,PassWord,UserName,UserId
HiddenPass = request.form("PwHidden")
PicNum = request.form("PicNum")
PassWord = strDecode(HiddenPass,trim(PicNum))
UserName = trim(request.form("LogName"))
Dim isLogin
SQL = "select UserID,UserName from U_User where LCase(UserName)='"&LCase(UserName)&"' and LCase(UserPass)='"&LCase(MD5(PassWord))&"'"
set Rs = Conn.execute(SQL)
if Rs.eof then
isLogin = False
else
isLogin = True
UserId = Rs("UserID")
UserName = Rs("UserName")
Session("AdminUserID") = UserId
Session("AdminUserName") = UserName
end if
Rs.close
set Rs = nothing
if isLogin then
Response.write "<script>parent.location.href='index.asp';</script>"
else
Response.write "<script>"
Response.write "parent.document.getElementById(""Form_UserName"").focus();"
Response.write "parent.document.getElementById(""errmsg"").innerHTML = '提示信息:用户名/密码错误!请重新输入!';"
Response.write "</script>"
end if
'服务端解密函数
function strDecode(sd_Data, sd_bassnum)
dim sd_vChar
dim sd_NewData
dim sd_TempChar
sd_vChar = 1
do
if sd_vChar > Len(sd_Data) then
exit do
end if
sd_TempChar = CLng(Mid(sd_Data, sd_vChar, 5))
sd_TempChar = ChrW(65535 + sd_bassnum - sd_TempChar)
sd_NewData = sd_NewData & sd_TempChar
sd_vChar = sd_vChar + 5
loop
strDecode = sd_NewData
end function
'异常错误处理
if err.number <> 0 then
logError err.number,forerr(err.source&":"&err.description)
err.clear
Response.end
end if
Conn.Close
set Conn = nothing
%>
追问
不要复制粘贴,请针对以上的问题回复一下,谢谢你的回答
追答
你仔细看看,这个是我之前系统的一个简单登陆页面,里面有判断用户是否存在
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询