<!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中,再跳轉到我們要處理的頁面。
%>