1.建立一个access数据库保存,打开“使用表设计器创建表”详细如下:
字段名称 数据类型
id 自动编号
username 文本
password 文本
2. login.asp 文件内容如下:
<html>
<head>
<title>系统管理员登陆</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script Language="javaScript">
function login_validate()
{
if (document.myform.username.value=="")
{
alert("Error:请输入帐号!");
document.myform.username.focus();
return false ;
}
if (document.myform.password.value=="")
{
alert("Error:请输入密码!");
document.myform.password.focus();
return false ;
}
return true;
}
</script>
<style type="text/css">
<!--
body,td {
font-size: 12px;
}
-->
</style>
</head>
<body>
<p> </p>
<form action="checkmima.asp" method="post" NAME="myform" id="myform" onSubmit="return
login_validate();">
<table width="250" border="0" align="center" cellpadding="5" cellspacing="1"
style="border:1px #cccccc solid;">
<tr>
<td height=30 bgcolor="#eeeeee" align=center>∷ 管理员登陆 ∷</td>
</tr>
<tr>
<td align="center">用户名: <input name="Username" tabindex="1" type="text"
id="username"></td>
</tr>
<tr>
<td align="center">密 码: <input name="Password" tabindex="2" type="password"
id="password"></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value=" 登 陆 "
tabindex="3">
<input type="reset" name="Submit2" value=" 重 置 " tabindex="4"></td>
</tr>
</table>
</form>
</body>
</html>
2. checkmima.asp 文件内容如下:
<%
db="数据库路径/数据库名称.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
'connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver(*.mdb)};"
conn.Open connstr
%>
<%
dim sql
dim rs
dim username
dim password
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
sql="select username,password,flag from zhuce where password='"&password&"' and
username='"&username&"'"
set rs = conn.execute(sql)
if not(rs.bof and rs.eof) then
if password=rs(1) then
session("admin")=rs(0)
session("flag")=rs(2)
Response.Redirect "Default.asp" // 登陆成功后要跳转到的页面
else
call Error
end if
else
call Error()
end if
sub Error()
Response.Write "<script language=javascript>"
Response.Write "alert(""登陆失败! 帐号或密码错误!"");"
Response.Write "history.back(-1);"
Response.Write "</script>"
end sub
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
上面是我找到的,帮我看看好吗?好象是checkmima.asp就有错误,没有正常运行,登陆立即无法显示。