1.connection.asp里的代码是: <% set conn=server.createobject("adodb.connection") conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("student.mdb") %> 2.yanzheng.asp里的代码是:
<!--#include file="connection.asp"--> <% dim zhanghao,mima zhanghao=request("zhanghao") mima=request("mima") if zhanghao="" then %> <script language=javascript> alert("帐号为空"); location.href="denglu.asp" </script> <% end if %> <% if mima="" then %> <script language=javascript> alert("密码为空"); location.href="denglu.asp" </script> <% end if %> <%set rs=server.createobject("adodb.recordset") rs.open "select * from student where zhanghao='"&zhanghao&"'",conn,1,3 if not rs.eof then if mima=rs("mima") then session("zhanghao")=zhanghao Response.write("<script>location.href('index.asp')</script>" ) else response.write ("<script>alert('用户密码错误');location.href('denglu.asp')</script>") end if end if if rs.eof then response.write ("<script>alert('用户帐号错误');location.href('denglu.asp')</script>") end if set rs=nothing rs.close %>接分
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("student.mdb")
%> 2.yanzheng.asp里的代码是:
<!--#include file="connection.asp"-->
<%
dim zhanghao,mima
zhanghao=request("zhanghao")
mima=request("mima")
if zhanghao="" then
%>
<script language=javascript>
alert("帐号为空");
location.href="denglu.asp"
</script>
<% end if %>
<% if mima="" then
%>
<script language=javascript>
alert("密码为空");
location.href="denglu.asp"
</script>
<% end if %>
<%set rs=server.createobject("adodb.recordset")
rs.open "select * from student where zhanghao='"&zhanghao&"'",conn,1,3
if not rs.eof then
if mima=rs("mima") then
session("zhanghao")=zhanghao
Response.write("<script>location.href('index.asp')</script>" )
else
response.write ("<script>alert('用户密码错误');location.href('denglu.asp')</script>")
end if
end if
if rs.eof then
response.write ("<script>alert('用户帐号错误');location.href('denglu.asp')</script>")
end if
set rs=nothing
rs.close %>接分