asp怎么判断数据库的用户名字段或密码字段是否为空??
下面这段代码是用于登录的asp页面代码,由VB程序提交到这个登录页面的。我想在这个页面增加一段代码来修改成的效果是:首先查询数据库,如果user字段不为空,但dl字段为空...
下面这段代码是用于登录的asp页面代码,由VB程序提交到这个登录页面的。我想在这个页面增加一段代码来修改成的效果是:首先查询数据库,如果user字段不为空,但dl字段为空,则提示:'未激活’。然后如果dl字段不为空才执行登录代码。
原先的登录代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%response.Expires=0%>
<%
private sub main()
dim dl,pass,state,errmsg
dl=request("dl")
pass=request.form("pass")
state=0
errmsg=""
if len(dl)=0 then
state=1
errmsg="用户名不能为空"
response.Write(errmsg)
exit sub
end if
if instr(1,dl," ")<>0 then
state=1
errmsg="用户名里面不能有空格"
response.Write(errmsg)
exit sub
end if
if instr(1,dl,"'")<>0 then
state=1
errmsg="用户名里面含有非法字符"
response.Write(errmsg)
exit sub
end if
if len(pass)=0 then
state=1
errmsg="密码不能为空"
response.Write(errmsg)
exit sub
end if
%>
<!--#include file="conn.asp" -->
<%
rs.open "select * from Users where Dl='" & dl & "' and Pass='" & pass & "'",con,1,1
if rs.bof and rs.eof then
rs.close
con.close
set rs=nothing
set con=nothing
state=1
errmsg="登陆失败,用户名或密码错误!!!"
response.Write(errmsg)
exit sub
else
rs.close
con.close
set rs=nothing
set con=nothing
state=0
'session("user")=user
response.Write("ok")
exit sub
end if
end sub
call main()
%>
请高手帮下,给完整代码,,谢谢了
有人知道吗?或者给我段如何判断的代码,如果表格里的user字段不为空,但dl字段为空,then 这个表达式如何写呢?
1楼的答案加上去后好像没用啊 展开
原先的登录代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%response.Expires=0%>
<%
private sub main()
dim dl,pass,state,errmsg
dl=request("dl")
pass=request.form("pass")
state=0
errmsg=""
if len(dl)=0 then
state=1
errmsg="用户名不能为空"
response.Write(errmsg)
exit sub
end if
if instr(1,dl," ")<>0 then
state=1
errmsg="用户名里面不能有空格"
response.Write(errmsg)
exit sub
end if
if instr(1,dl,"'")<>0 then
state=1
errmsg="用户名里面含有非法字符"
response.Write(errmsg)
exit sub
end if
if len(pass)=0 then
state=1
errmsg="密码不能为空"
response.Write(errmsg)
exit sub
end if
%>
<!--#include file="conn.asp" -->
<%
rs.open "select * from Users where Dl='" & dl & "' and Pass='" & pass & "'",con,1,1
if rs.bof and rs.eof then
rs.close
con.close
set rs=nothing
set con=nothing
state=1
errmsg="登陆失败,用户名或密码错误!!!"
response.Write(errmsg)
exit sub
else
rs.close
con.close
set rs=nothing
set con=nothing
state=0
'session("user")=user
response.Write("ok")
exit sub
end if
end sub
call main()
%>
请高手帮下,给完整代码,,谢谢了
有人知道吗?或者给我段如何判断的代码,如果表格里的user字段不为空,但dl字段为空,then 这个表达式如何写呢?
1楼的答案加上去后好像没用啊 展开
展开全部
又修改了下:
<%
rs.open "select * from Users where user='" & dl & "' and Pass='" & pass & "'",con,1,1
if rs.bof and rs.eof then
rs.close
con.close
set rs=nothing
set con=nothing
state=1
errmsg="登陆失败,用户名或密码错误!!!"
response.Write(errmsg)
exit sub
else
if IsNull(rs("dl")) or rs("dl") = "" then
state=1
errmsg="该账号未激活!!!"
response.Write(errmsg)
exit sub
end if
rs.close
con.close
set rs=nothing
set con=nothing
state=0
'session("user")=user
response.Write("ok")
exit sub
end if
end sub
call main()
%>
<%
rs.open "select * from Users where user='" & dl & "' and Pass='" & pass & "'",con,1,1
if rs.bof and rs.eof then
rs.close
con.close
set rs=nothing
set con=nothing
state=1
errmsg="登陆失败,用户名或密码错误!!!"
response.Write(errmsg)
exit sub
else
if IsNull(rs("dl")) or rs("dl") = "" then
state=1
errmsg="该账号未激活!!!"
response.Write(errmsg)
exit sub
end if
rs.close
con.close
set rs=nothing
set con=nothing
state=0
'session("user")=user
response.Write("ok")
exit sub
end if
end sub
call main()
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |