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>無標題文檔</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <label>
  <input type="text" name="name" id="textfield" />
  </label>
  <p>
    <label>
    <input type="text" name="pwd" id="textfield2" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="提交" />
    </label>
  </p>
</form>
</body>
</html>
<%
if request.form("name")<>"" then
 login()
end if
function login()
dim sql,username,userpwd,user
   username=html_encode(request.form("name"))
   userpwd=html_encode(request.form("pwd"))
   user=request.form("user")
   if len(username)<4 or len(username)>16 then
      response.write("<script language='javascript教程'>alert('對不起,使用者名稱不合法!');history.back();</script>")
   response.end
 end if
   if len(userpwd)<4 or len(userpwd)>16 then
      response.write("<script language='javascript'>alert('對不起,密碼不合法!');history.back();</script>")
   response.end
 end if
   if  cint(user)<>session("user") then
      response.write("<script language='javascript'>alert('對不起,驗證碼錯誤!');history.back();</script>")
      response.end
   end if
   sql="select * from reg where username='"&username&"' and password='"&userpwd&"'"
     call opensql()
  sqlrs.open sql,sqlcn
  if not sqlrs.eof then
    session("username")=username
    response.redirect("../usermange.asp?user="&username)
   else
   response.write("<script language='javascript'>alert('對不起,登入失敗使用者名稱不存在,請重新再試!');history.back();</script>")
   end if
end function

'說明 首先是擷取使用者提供的使用者名稱與密碼,然後再進行資料比較判斷,如果不合法就不讓查詢資料庫教程,如果通過規則驗證驗證就進行資料庫使用者名稱與密碼驗證,驗證通過了就把使用者名稱儲存到session中,再跳轉到我們要處理的頁面。
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.