求ASP简单源码!

如题所述

超简单的代码,适合入门的时候用,共6个文件,其中data.mdb是数据库文件,enter.htm是登陆界面,ent_submit.asp是判断能否成功登陆的文件,login.asp是登陆成功后跳转到的页面,register.htm是注册会员的界面,reg_submit.asp是处理注册信息的文件。

1.enter.htm文件

<!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="ent_submit.asp">
<p> </p>
<p>用户名:
<input name="username" type="text" id="username" size="20">
</p>
<p>密 码:
<input name="password" type="password" id="password" size="16">
</p>
<p>
<input type="submit" name="Submit" value="登陆">
<a href="register.htm">注册为会员</a></p>
</form>
</body>
</html>

2.ent_submit.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>
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data.mdb")
username=request.form("username")
password=request.form("password")
sql="select * from user where username='"+username+"' and password='"+password+"'"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof then
response.Write("<script>alert('用户名或密码错误,请重新输入!');history.back(-1)</script>")
else
response.Write("<script>alert('登录成功!');history.back(-1)</script>")
response.redirect"login.asp"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>

3.login.asp文件

<!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>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>

<body>

<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p class="style1">成功登录转到该页面</p>
</div>
</body>
</html>

4.register.htm文件

<!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>
<style type="text/css">
<!--
.style1 {font-size: 14px}
-->
</style>
</head>

<body class="style1">
<form name="form1" method="post" action="reg_submit.asp">
<p> </p>
<p>用户名:
<input name="username" type="text" id="username" size="20">
</p>
<p>密 码:
<input name="password" type="password" id="password" size="16">
</p>
<p>
<input type="submit" name="Submit" value="注册">
<a href="enter.htm">返回登录页面</a></p>
</form>
</body>
</html>

5.reg_submit.asp文件

<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data.mdb")
username=request.form("username")
password=request.form("password")
exec="select * from user where username='"&username&"'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1

if username="" or password="" then
response.Write("<script>alert('用户名或密码不能为空!');history.back()</script>")
else
if not rs.eof then
response.Write("<script>alert('对不起,该帐号已有人注册了,请重新输入!');history.back() </script>")
else
sql="insert into user(username,password) values('"+username+"','"+password+"')"
conn.execute sql
response.write("<script>alert('注册成功!');history.back()</script>")
end if
end if

rs.close
set rs=nothing
conn.close
set conn=nothing
%>

6.data.mdb文件

这个需要你自己建立一个名为data.mdb的ACCESS数据库,没有安ACCESS的需要先安装好,然后在data.mdb里面再建立一个名为USER的表,表字段如下:
id:自动编号
username:文本型
password:文本型
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-10-13
源码太多了,你想到哪一类的?

可以在百度内给我消息,或者直接上chinaz.com 去下载,还可以去百度搜你想要的具体代码本回答被网友采纳
相似回答
大家正在搜