请教一个 asp 记住登陆状态的代码
登陆页面------------------------------------------<tablewidth="35%"border="0"align="cente...
登陆页面
------------------------------------------
<table width="35%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="9" align="right" valign="bottom"> </td>
<td width="87" align="right" valign="bottom"><span class="STYLE1">用户名:</span></td>
<td width="176" height="24" align="center" valign="bottom"><input type="text" name="name" id="textfield" style="width:150px; height:21px; background-color:#87adbf; border:solid 1px #153966; font-size:12px; color:#283439; " /></td>
</tr>
<tr>
<td width="9" height="24" align="right" valign="bottom"> </td>
<td width="87" align="right" valign="bottom"><span class="STYLE1">密 码:</span></td>
<td rowspan="2" align="center" valign="middle"><input type="password" name="password" id="password" style="width:150px; height:21px; background-color:#87adbf; border:solid 1px #153966; font-size:12px; color:#283439;" /></td>
</tr>
<tr>
<td height="24" colspan="2" valign="bottom" class="dd">记住密码一周
<input name="mima" type="checkbox" id="mima" value="checkbox" /></td>
</tr>
</table>
-------------------------
登陆验证页的代码
-----------------------------------------------------------
<%
dim name,password
name=request.form("name")
password=request.form("password")
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
session("checked")="yes"
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
session("checked")="no"
session("check")="wrong"
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------------------------
登陆成功的页码 GG_admin_manage.asp
----------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if not session("checked")="yes" then
response.Redirect "login.asp"
else
%>
请问如何修改代码让 用户勾选了登陆页【记住密码】登陆后!~下次访问GG_admin_manage.asp页面的时候如果选了记住密码!~以后打开GG_admin_manage.asp就不需要登陆了
还没有满意的答案大家加油呀!!!! 展开
------------------------------------------
<table width="35%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="9" align="right" valign="bottom"> </td>
<td width="87" align="right" valign="bottom"><span class="STYLE1">用户名:</span></td>
<td width="176" height="24" align="center" valign="bottom"><input type="text" name="name" id="textfield" style="width:150px; height:21px; background-color:#87adbf; border:solid 1px #153966; font-size:12px; color:#283439; " /></td>
</tr>
<tr>
<td width="9" height="24" align="right" valign="bottom"> </td>
<td width="87" align="right" valign="bottom"><span class="STYLE1">密 码:</span></td>
<td rowspan="2" align="center" valign="middle"><input type="password" name="password" id="password" style="width:150px; height:21px; background-color:#87adbf; border:solid 1px #153966; font-size:12px; color:#283439;" /></td>
</tr>
<tr>
<td height="24" colspan="2" valign="bottom" class="dd">记住密码一周
<input name="mima" type="checkbox" id="mima" value="checkbox" /></td>
</tr>
</table>
-------------------------
登陆验证页的代码
-----------------------------------------------------------
<%
dim name,password
name=request.form("name")
password=request.form("password")
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
session("checked")="yes"
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
session("checked")="no"
session("check")="wrong"
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------------------------
登陆成功的页码 GG_admin_manage.asp
----------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if not session("checked")="yes" then
response.Redirect "login.asp"
else
%>
请问如何修改代码让 用户勾选了登陆页【记住密码】登陆后!~下次访问GG_admin_manage.asp页面的时候如果选了记住密码!~以后打开GG_admin_manage.asp就不需要登陆了
还没有满意的答案大家加油呀!!!! 展开
展开全部
<%
'验证页面
dim name,password
name=request.form("name")
password=request.form("password")
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
response.cookies( "checked ").path= "/ "
response.cookies( "checked ")= "yes "
response.Cookies("checked").expires=date+360
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------
登录成功页面!
----------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if request.cookies("checked")<>"yes" then
response.Redirect "login.asp"
else
response.write"你已成功登录!"
end if
%>
以上我只做了一下登录状态的判断!至于其它的灵活运用即可!
'验证页面
dim name,password
name=request.form("name")
password=request.form("password")
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
response.cookies( "checked ").path= "/ "
response.cookies( "checked ")= "yes "
response.Cookies("checked").expires=date+360
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------
登录成功页面!
----------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if request.cookies("checked")<>"yes" then
response.Redirect "login.asp"
else
response.write"你已成功登录!"
end if
%>
以上我只做了一下登录状态的判断!至于其它的灵活运用即可!
更多追问追答
追问
你好谢谢你的解答,朋友做掉了我登陆页面的 【记录密码一周的选项】如果选择了才记录密码一周没有选择不记录
追答
----------------------------------------------------------------------
登录成功页面
----------------------------------------------------------------------
"yes" then
response.Redirect "login.asp"
else
response.write"你已成功登录!"
end if
%>
展开全部
<%@ LANGUAGE = VBScript.Encode %>
<!--#include file="conn.asp"-->
<!--#include file="../class/Config.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if CheckCode="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>验证码不能为空!</li>"
end if
if session("CheckCode")="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
end if
if CheckCode<>CStr(session("CheckCode")) then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where password='"&password&"' and username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
`设置session及有效时间,希望能帮你
session.Timeout=SessionTimeout
session("AdminName")=rs("username")
session("AdminPassword")=rs("Password")
session("RndPassword")=RndPassword
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "default.asp"
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='tdbg'><a href='Login.asp'><< 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
Function GetRndPassword(PasswordLen)
Dim Ran,i,strPassword
strPassword=""
For i=1 To PasswordLen
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
strPassword = strPassword & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & Chr(Ran)
End If
Next
GetRndPassword=strPassword
End Function
%>
希望能帮你,祝你成功。
<!--#include file="conn.asp"-->
<!--#include file="../class/Config.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if CheckCode="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>验证码不能为空!</li>"
end if
if session("CheckCode")="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
end if
if CheckCode<>CStr(session("CheckCode")) then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where password='"&password&"' and username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
RndPassword=GetRndPassword(16)
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs("RndPassword")=RndPassword
rs.update
`设置session及有效时间,希望能帮你
session.Timeout=SessionTimeout
session("AdminName")=rs("username")
session("AdminPassword")=rs("Password")
session("RndPassword")=RndPassword
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "default.asp"
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()
'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='tdbg'><a href='Login.asp'><< 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
Function GetRndPassword(PasswordLen)
Dim Ran,i,strPassword
strPassword=""
For i=1 To PasswordLen
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
strPassword = strPassword & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
strPassword =strPassword & Chr(Ran)
End If
Next
GetRndPassword=strPassword
End Function
%>
希望能帮你,祝你成功。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
登陆验证页的代码
-----------------------------------------------------------
<%
dim name,password
name=request.form("name")
password=request.form("password")
mima=request.form("mima")'获取复选框是否选中'
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
session("checked")="yes"
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
if mima<>"" then'判断是否选中 选中则记录cookie'
Response.Cookies("state")=""
Response.Cookies("state").expires=date+7
End if
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
session("checked")="no"
session("check")="wrong"
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------------------------
登陆成功的页码 GG_admin_manage.asp
----------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if Request.Cookies("state")<>"checkbox" then '如果cookies不等于checkbox则未记录用户名'
response.Redirect "login.asp"
else
%>
-----------------------------------------------------------
<%
dim name,password
name=request.form("name")
password=request.form("password")
mima=request.form("mima")'获取复选框是否选中'
dim sql,conn,rs
sql="select * from [check] where(name='"&name&"' and password='"&password&"')"
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("/mdb/db.mdb")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn
if not rs.eof then
session("checked")="yes"
session("check")="right"
Session("qx")=rs("aaa")
session("name")=name
if mima<>"" then'判断是否选中 选中则记录cookie'
Response.Cookies("state")=""
Response.Cookies("state").expires=date+7
End if
rs.Close
conn.Close
response.Redirect "GG_admin_manage.asp"
else
rs.Close
conn.Close
session("checked")="no"
session("check")="wrong"
response.Redirect "login.asp"
end if
%>
----------------------------------------------------------------------------------------
登陆成功的页码 GG_admin_manage.asp
----------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%if Request.Cookies("state")<>"checkbox" then '如果cookies不等于checkbox则未记录用户名'
response.Redirect "login.asp"
else
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
到百度搜索“asp Cookies 记住密码”,一大堆现成的代码和教学
追问
我要现成改的不想找了~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询