asp使用者登入,退出登入函數

來源:互聯網
上載者:User

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>asp教程使用者登入,退出登入函數</title>
</head>

<body>
<form action="login.asp" method="post" name="loginform" id="loginform" onsubmit="return check();">
        <table width="500"  border="0" cellspacing="5" cellpadding="0">
  <tr>
    <td><strong>使用者名稱:</strong>      <input type="text" size="20" name="username">
      <strong>密 碼:</strong>      <input name="userpass" type="password" id="userpass" size="20"></td>
  </tr>
  <tr>
    <td>保持登入:
      <input name="issave" type="radio" value="0">
      不儲存
      <input name="issave" type="radio" value="1" checked>
      保持一天
      <input type="radio" name="issave" value="30">
      保持一個月
      <input type="submit" name="submit" value="登入"></td>
  </tr>
</form>
</body>
</html>


login.asp

<%
on error resume next
set conn=server.createobject("adodb.connection")
conn.open connstr
if err then
 response.write ""&issqlver&"資料庫教程串連出錯,請檢查串連字串。<br><br>"&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
%> 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.