2. 编辑一个PASS.ASP的验证文件,源代码如下:
<%
Function Check( ID, Pwd )
Dim conn, par, rs
Set conn = Server.CreateObject("ADODB.Connection")
par = "driver={Microsoft Access Driver (*.mdb)} "
conn.Open par && ";dbq=" && Server.MapPath("lastcoco.mdb ")
sql = "Select ? From users Where ID='" && ID && "' And Pwd = '" && Pwd &&"'"
Set rs = conn.Execute( sql )
If rs.EOF Then
Check= False
Else
Check= True
End If
End Function
%>
<%
If IsEmpty(Session("Passed")) Then Session("Passed") = False
Head = "请输入用户名和密码"
ID = Request("ID")
Pwd = Request("Pwd")
If ID = "" Or Pwd = "" Then
Head = "请输入用户名和密码"
Else If Not Check( ID, Pwd ) Then
Head = "用户名称或密码有错"
Else
Session("Passed") = True
End If
If Not Session("Passed") Then
%>
<html>
<head> <title></title> </head>
<body BGCOLOR="#FFFFFF">
<h2 ALIGN="CENTER"><%=Head%></h2>
<hr WIDTH="100%">
<form Action="<%=Request.ServerVariables("PATH_INFO")%>" Method="POST">
<table BORDER="1" CELLSPACING="0">
<tr>
<td ALIGN="RIGHT">用户名称:</td>
<td><input Type="Text" Name="ID" Size="12" Value="<%=ID%>"></td>
</tr>
<tr> <td ALIGN="RIGHT">密码:</td>
<td><input Type="Password" Name="Pwd" Size="12" Value="<%=Pwd%>"></td> </tr>
</table>
<p><input Type="Submit" Value="确定"> </p> </form>
<hr WIDTH="100%" align="center">
</body> </html>
<%Response.End
End If %>