【www.gdgbn.com--php函数】





<a href="http://www.gdgbn.com/blist-14-1.html" target="_blank" class="keylink">asp教程</a>用户登录,退出登录函数



       
 
    用户名:     
      密 码:     
 
 
    保持登录:
     
      不保存
     
      保持一天
     
      保持一个月
     
 



login.asp

<%
on error resume next
set conn=server.createobject("adodb.connection")
conn.open connstr
if err then
 response.write ""&issqlver&"数据库教程连接出错,请检查连接字串。

"&err.source&" ("&err.number&")"
 set conn = nothing
 err.clear
 response.end
end if


dim expires,userpass
username=request("username")
userpass=md5(request("userpass"),16)
expires=request("issave")
if username<>"test" then

set rs=server.createobject("adodb.recordset")
rs.open"select * from lg50_my_user where username=""&username&"" and password=""&userpass&""",conn,1,3
if rs.eof and rs.bof then
 rs.close
 set rs=nothing
 response.write("<script language=网页特效>alert("请输入正确用户名和密码");this.location.href="login.htm";</script>")
 response.end
else
   response.cookies(cookiesname)("username")=username
   if int(expires)>0 then response.cookies(cookiesname).expires = date+expires
      response.redirect ("index.asp")
end if

else
   response.cookies(cookiesname)("username")=username
      response.redirect ("index.asp")
   response.end
end if
%>


退出登录

<%
if request("out")="bbs" then
   response.cookies(cookiesname)("username")=""
   response.redirect "/www.111cn.net/login.asp?menu=out&bbs=bbs"
else
  response.cookies(cookiesname)("username")=""
  response.redirect ("login.htm")
end if
%> 

本文来源:http://www.gdgbn.com/jiaocheng/27703/