注册 登录
编程论坛 ASP技术论坛

身份证验证问题

冰雪飘飘 发布于 2008-04-19 00:46, 1551 次点击
身份验证页面session.asp代码如下:
<%
If Session("admin")="" then
  response.Redirect "index.htm"
end if
%>
我在admin_index.asp中包含这个session.asp文件后,是不可以进入admin_index.asp页面,但是我在index.htm页面输入登入后,还是无法登陆。请问这是为什么?Session("admin")=""中的admin是什么定义的
10 回复
#2
madpbpl2008-04-19 01:45
查看你的会员添加表单提交到的页面
Session("admin")指的是用户名  '一般情况下
#3
冰雪飘飘2008-04-19 09:35
登陆页面被提交到logincheck.asp进行验证,其代码如下:
<!--#include file="conn.asp"-->
<%
uid=trim(Request("name_id"))
upwd=trim(Request("password"))
if uid="" or upwd="" then
response.write ("<script language=javascript>alert('用户名和密码不能为空!');history.go(-1);</script>")
'判断帐号及密码是否正确
else
set rs=server.Createobject("adodb.recordset")
str="select * from [admin]"
rs.open str,conn,1,3
if uid=rs("name_id") and upwd=rs("password") then
Session("admin")=uid
response.redirect "admin_Index.asp"
else
response.write ("<script language=javascript>alert('用户名和密码不匹配,请重新输入!');history.go(-1);</script>")
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
#4
永夜的极光2008-04-19 09:45
Session("admin")=uid
看看这一句,Session("admin")的值就是uid,uid是上个页面传递过来的值

看看下面的对于session对象的介绍
http://www.
#5
冰雪飘飘2008-04-19 09:56
谢谢!
那为什么我输入了正确的用户名之后还是登陆不了呢?总是会回到登陆界面
#6
madpbpl2008-04-19 11:36
str="select * from [admin]"
rs.open str,conn,1,3
if uid=rs("name_id") and upwd=rs("password") then
改成
str="select * from [admin] where name_id='" & uid & "' and password='" & upwd & "'"    '这里假设用户名是文本类型
rs.open str,conn,1,3
if not (rs.eof and rs.bof) then
#7
冰雪飘飘2008-04-19 13:22
谢谢madpbpl!
我按了你的改,现在是可以登陆进入admin_index.asp页面了,可是也可以直接进去,根本没有起到身份验证的效果,能不能帮忙再看一下?我对ASP不是很了解
#8
冰雪飘飘2008-04-19 13:27
为什么第一次可以实现,可是再重新登陆是时候却不可以?是不是session(admin)可以存储?
#9
madpbpl2008-04-19 13:31
<!--#include file="conn.asp"-->
<%
uid=trim(Request("name_id"))
upwd=trim(Request("password"))
if uid="" or upwd="" then
response.write ("<script language=javascript>alert('用户名和密码不能为空!');history.go(-1);</script>")
'判断帐号及密码是否正确
Response.end
end if
set rs=server.Createobject("adodb.recordset")
str="select * from [admin] where name_id='" & uid & "' and password='" & upwd & "'"    '这里假设用户名是文本类型
rs.open str,conn,1,3
if rs.eof and rs.bof then
Response.Write "<script language=JavaScript>alert('用户名和密码不匹配,请重新输入! ');"
Response.Write "javascript:history.go(-1)</script>"
Response.End
else
Session("admin")=uid
response.redirect "admin_Index.asp"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
#10
yms1232008-04-19 16:57
楼主可以设置一下Session.Timeout=50更长的过期时间。
#11
冰雪飘飘2008-04-19 21:38
问题已经解决,感谢各位!
1