这是登入表单代码:
<body>
<form id="form1" name="dl" method="post" action="logon.asp" >
<table width="350" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="83">用户名</td>
<td width="253"><label>
<input type="text" name="Name" id="Name" />
</label></td>
</tr>
<tr>
<td>密码</td>
<td><label>
<input type="text" name="Password" id="Password" />
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="button" name="button" id="button" value="提交" onclick=check()/>
<input type="reset" name="button2" id="button2" value="重置" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
<script language=vbscript>
sub check()
if document .dl.Name.value="" then
msgbox("请输入用户名!",48)
document.dl.Name.focus()
else if
document.dl.Password.value=“” then
msgbox("请输入密码!",48)
document.dl.Password.focus()
else
document.dl.submit
end if
end sub
</script>
这是处理表单代码
<%
Name=Request.Form("Name")
Password=Request.Form("Password")
db=asptest.mdb
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
Set rst=Server.CreateObject("ADODB.Recordset")
strSQL ="Select * from UseraLogon Where Name='"&Name&"' AND Password='"&Password&"'"
rst.open strSQL, conn,3
if rst.RecordCount=0 then
%>
<script language=vbscript>
msgbox("用户名或密码不正确!",48)
window.history.go(-1)
</script>
<%
else
Session("Name")=rst("Name")
Session("UserID")=rst("ID")
%>
<script language=vbscrit>
msgbox("用户登录成功!",48)
window.location="index.asp"
</script>
<%end if
conn.Close
set conn=nothing
%>