新手、登录跳转问题

dw1178769973 2011-06-03 06:53:05
<%
if request("action")="dl" then
if cstr(Session("Num"))<>cstr(trim(request("yz"))) then
response.Write "<script LANGUAGE=javascript>alert('请输入正确的验证码!'); </script>"
response.write "<meta http-equiv=refresh content=""1;URL=login.asp"">"
else
call dl()
end if
end if
sub dl()
name=Trim(Request.Form("name"))
pass=Trim(Request.Form("pass"))
sql="select * from admin where(username='"&name&"' and password='"&pass&"')"
set rs=server.createobject("adodb.recordset")
rs.open sql,con,1,1

if not rs.eof then
if rs("shenhe")=0 then
qxid=rs("qxid")
id=rs("userid")
j="true"
session("j")=j
session("userid")=id
if qxid=1 then
session("qxid")=1
response.Redirect "gly.asp"
else if qxid=2 then
session("qxid")=2
response.Redirect "gly.asp"
else if qxid=3 then
session("qxid")=3
response.Redirect "cz_index.asp?j="&j
else if qxid=4 then
session("qxid")=4
response.Redirect "kz_index.asp?j="&j
else if qxid=5 then
session("qxid")=5
response.Redirect "py_ck.asp?j="&j
else if qxid=6 then
session("qxid")=6
response.Redirect "gly_index.asp?j="&j
end if
end if
end if
end if
end if
end if
end if
else if rs("sh")=1 then
response.Write("您的账号未审核,暂不能登录,请联系管理员")
end if
end if
else
response.Write("您的账号不存在")


end sub



%>
总是提示我缺少end、是哪里出错了
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
freejanker 2011-06-04
  • 打赏
  • 举报
回复
你这也确实太多if else了。
你在这两行的下面:
else
response.Write("您的账号不存在")

加一个end if试试
toury 2011-06-04
  • 打赏
  • 举报
回复
后面忘记释放数据库资源了。看这个

<%
if request("action")="dl" then
if cstr(Session("Num"))<>cstr(trim(request("yz"))) then
response.Write "<script LANGUAGE=javascript>alert('请输入正确的验证码!'); </script>"
response.write "<meta http-equiv=refresh content=""1;URL=login.asp"">"
response.end
end if

call dl()
end if

sub closeDB(o)
if not isobject(o) then exit sub
if o.state<>0 then o.close
set o=nothing
end sub

sub dl()
name=Trim(Request.Form("name"))
pass=Trim(Request.Form("pass"))
sql="select * from [admin] where(username='"&name&"' and password='"&pass&"')"
set rs=server.createobject("adodb.recordset")
rs.open sql,con,1,1

if rs.eof then
call closeDB(rs)
call closeDB(con)
response.Write("您的账号不存在")
response.end
end if

if rs("shenhe")=0 then
qxid=rs("qxid")
id=rs("userid")
j="true"
session("j")=j
session("userid")=id

select case qxid
case 1,2: url="gly.asp"
case 3 : url="cz_index.asp?j="&j
case 4 : url="kz_index.asp?j="&j
case 5 : url="py_ck.asp?j="&j
case 6 : url="gly_index.asp?j="&j
end select

if url<>"" then
call closeDB(rs)
call closeDB(con)
response.Redirect url
end if
else if rs("sh")=1 then
response.Write("您的账号未审核,暂不能登录,请联系管理员")
else
'''预留功能
end if
call closeDB(rs)
call closeDB(con)
end sub
%>

toury 2011-06-04
  • 打赏
  • 举报
回复
这样试试:

<%
if request("action")="dl" then
if cstr(Session("Num"))<>cstr(trim(request("yz"))) then
response.Write "<script LANGUAGE=javascript>alert('请输入正确的验证码!'); </script>"
response.write "<meta http-equiv=refresh content=""1;URL=login.asp"">"
response.end
end if

call dl()
end if

sub closeDB(o)
if not isobject(o) then exit sub
if o.state<>0 then o.close
set o=nothing
end sub

sub dl()
name=Trim(Request.Form("name"))
pass=Trim(Request.Form("pass"))
sql="select * from [admin] where(username='"&name&"' and password='"&pass&"')"
set rs=server.createobject("adodb.recordset")
rs.open sql,con,1,1

if rs.eof then
call closeDB(rs)
call closeDB(con)
response.Write("您的账号不存在")
response.end
end if

if rs("shenhe")=0 then
qxid=rs("qxid")
id=rs("userid")
j="true"
session("j")=j
session("userid")=id

select case qxid
case 1,2: url="gly.asp"
case 3 : url="cz_index.asp?j="&j
case 4 : url="kz_index.asp?j="&j
case 5 : url="py_ck.asp?j="&j
case 6 : url="gly_index.asp?j="&j
end select

if url<>"" then response.Redirect url
else if rs("sh")=1 then
response.Write("您的账号未审核,暂不能登录,请联系管理员")
else
'''预留功能
end if
end sub
%>

vstudiocn 2011-06-04
  • 打赏
  • 举报
回复
else
response.Write("您的账号不存在")


end sub

这里明显少了个end if
xzf888 2011-06-04
  • 打赏
  • 举报
回复
else if 应该是连起来的就像3楼tcwsyt说的一样,你的最后好像还少一个

else
response.Write("您的账号不存在")

end if
end sub



%>
灬上海爽爷 2011-06-04
  • 打赏
  • 举报
回复
if xxx then

elseif xxx then

else

end if


应该是这样的格式..
fengyun817 2011-06-03
  • 打赏
  • 举报
回复
你这if else 太多了.自己好好检查.

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧