1个回答
展开全部
时间关系,没给你写 所以就复制了一段 可到我论坛看看
http://forum.liehuo.net/
代码如下:
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
%>
二、
conn.asp
<%
Set conn=Server.CreateObject("ADODB.Connection")
connstr="DBQ="+server.mappath("haha.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
conn.Open connstr
%>
index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="login.asp">
<table width="50%" height="108" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>用户名:</td>
<td><input name="us" type="text" id="us"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="pa" type="password" id="pa" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
login.asp
<!--#include file="conn.asp"-->
<%
us=replace(request.form("us"),"'","’")
pa=replace(request.form("pa"),"'","’")
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from haha where us='"&us&"' and pa='"&pa&"'"
rs.open sql,conn,1,1
%>
<%
if rs.eof or rs.bof then
response.write"密码错误~"
else
response.redirect"main.asp"
end if
%>
三、
连接数据库(conn.asp)
<%
dim db,conn,connstr
db="@data.mdb"
set Conn = server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="& server.MapPath("../data/"&db&"")
conn.Open connstr
%>
登录页面(login.asp)
<% @language=vbscript %>
<!--#include file="conn.asp"-->
<%
On Error Resume Next
dim uid
dim pwd
uid=trim(request.Form("uid")) '获得用户名
pwd=trim(request.form("pwd")) '获得密码
dim rs
set rs=server.createobject("adodb.recordset")
if uid<>"" then
dim sqlstr
sqlstr="select uid,pwd from admin where uid='"&replace(uid,"'","''")&"' and pwd='"&replace(pwd,"'","''")&"'"
rs.open sqlstr,conn,3,1
if not rs.eof then
session("uid")=uid
response.redirect "login_ok.asp" '重定位url
else
response.redirect "error.htm"
end if
else
response.redirect "error.htm"
end if
%>
http://forum.liehuo.net/
代码如下:
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
%>
二、
conn.asp
<%
Set conn=Server.CreateObject("ADODB.Connection")
connstr="DBQ="+server.mappath("haha.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
conn.Open connstr
%>
index.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="login.asp">
<table width="50%" height="108" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>用户名:</td>
<td><input name="us" type="text" id="us"></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="pa" type="password" id="pa" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
login.asp
<!--#include file="conn.asp"-->
<%
us=replace(request.form("us"),"'","’")
pa=replace(request.form("pa"),"'","’")
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from haha where us='"&us&"' and pa='"&pa&"'"
rs.open sql,conn,1,1
%>
<%
if rs.eof or rs.bof then
response.write"密码错误~"
else
response.redirect"main.asp"
end if
%>
三、
连接数据库(conn.asp)
<%
dim db,conn,connstr
db="@data.mdb"
set Conn = server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="& server.MapPath("../data/"&db&"")
conn.Open connstr
%>
登录页面(login.asp)
<% @language=vbscript %>
<!--#include file="conn.asp"-->
<%
On Error Resume Next
dim uid
dim pwd
uid=trim(request.Form("uid")) '获得用户名
pwd=trim(request.form("pwd")) '获得密码
dim rs
set rs=server.createobject("adodb.recordset")
if uid<>"" then
dim sqlstr
sqlstr="select uid,pwd from admin where uid='"&replace(uid,"'","''")&"' and pwd='"&replace(pwd,"'","''")&"'"
rs.open sqlstr,conn,3,1
if not rs.eof then
session("uid")=uid
response.redirect "login_ok.asp" '重定位url
else
response.redirect "error.htm"
end if
else
response.redirect "error.htm"
end if
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询