当前位置:首页 » 操作系统 » asp登陆源码

asp登陆源码

发布时间: 2024-06-23 14:59:49

⑴ asp程序实现简单的注册,登录网页的源代码

1,(index.asp 用户登陆页面)
<!-- #include file="conn.asp" -->
<!-- blog.soowooo.cn 悠悠长假期 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>会员</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
-->
</style>
</head>
<body>
<center>
<p>会员注册系统</p>
<form name="form1" method="post" action="login.asp">
<table width="34%" border="0">
<tr>
<td width="33%" height="30">用户名:</td>
<td width="67%" height="30"><input name="username" type="text" id="username" size="15"></td>
</tr>
<tr>
<td height="30">密 码:</td>
<td height="30"><input name="password" type="password" id="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="确定">
<input type="reset" name="Submit" value="重置"></td>
</tr>
<tr>
<td colspan="2"><a href="reg.asp" target="_self">注册</a></td>
</tr>
</table>
</form>
</center>
</body>

</html>

2,(login.asp 用户数据处理文件)

<!-- #include file="conn.asp" -->
<%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"&request.Form("username")&"' and password='"&request.Form("password")&"'"
rsc.open sqlc,conn,1,1
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
set rsc=nothing
response.Redirect("change.asp")
'如果用户不存在,session("username")为空
%>
3,(change.asp 用户信息修改页面)
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改</title>
<style type="text/css">
<!--
body,td,th {
font-size: 14px;
}
-->
</style></head>
<center>
<body>
<br>
<%

set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"&session("username")&"' and password='"&session("password")&"'"
rsc.open sqlc,conn,1,1
nr=rsc("password")
username=rsc("username")
password=rsc("password")
sex=rsc("sex")
qq=rsc("qq")
mail=rsc("mail")
add=rsc("add")
personalinfo=rsc("personalinfo")
vv=rsc("ntime")
set rsc=nothing
if nr="" then
response.Redirect("index.asp")
end if
if strcomp(nr,request.Form("password"))=0 then
response.Write("欢迎你!"&request.Form("username"))
response.Write("你是在"&vv&"注册的")
session("username")=request.Form("username")
end if
if session("username")="" then
response.Redirect("index.asp")
end if
%>
<form name="form1" method="post" action="change.asp?ac=ch">
<table width="39%" height="105" border="0" >
<tr>
<td width="27%" height="30">用户名:</td>
<td width="73%" height="30"><input name="username" type="text" id="username" value="<%=username%>">
*</td>
</tr>
<tr>
<td height="30">密 码:</td>
<td height="30"><input name="password" type="text" id="password" value="<%=password%>">
*</td>
</tr>
<tr>
<td height="30">性 别:</td>
<td height="30"><input name="sex" type="text" id="sex" value="<%=sex%>"></td>
</tr>
<tr>
<td height="30">QQ:</td>
<td height="30"><input name="qq" type="text" id="qq" value="<%=qq%>"></td>
</tr>
<tr>
<td height="30">Mail:</td>
<td height="30"><input name="mail" type="text" id="mail" value="<%=mail%>"></td>
</tr>
<tr>
<td height="30">地 址:</td>
<td height="30"><input name="add" type="text" id="add" value="<%=add%>"></td>
</tr>
<tr>
<td>介绍</td>
<td><textarea name="personalinfo" cols="30" rows="6" id="personalinfo"><%=personalinfo%></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="修改">
<a href="change.asp?se=y" target="_self">退出系统</a></td>
<% if strcomp(request.QueryString("se"),"y")=0 then
session("username")=""
response.Redirect("index.asp")
end if
%>
</tr>
</table>
</form>
<%
if strcomp(request.QueryString("ac"),"ch")=0 then
set rs=server.createobject("adodb.recordset")
sql="select * from info where username='"&session("username")&"'"
rs.open sql,conn,1,3
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs.update
set rs=nothing
response.Write("修改完成!")
end if
%>
</body>
</center>
</html>
4,(reg.asp 新用户注册页面)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户注册</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体;
font-size: 14px;
}
-->
</style>
</head>
<body>
<center>
用户注册<br>
<%
=request.QueryString("msg")
%>
<form name="form1" method="post" action="addnewdata.asp?ac=adser">
<table width="39%" height="105" border="0" >
<tr>
<td width="27%" height="30">用户名:</td>
<td width="73%" height="30"><input name="username" type="text" id="username">
*</td>
</tr>
<tr>
<td height="30">密码:</td>
<td height="30"><input name="password" type="password" id="password">
*</td>
</tr>
<tr>
<td height="30">确定密码:</td>
<td height="30"><input name="password2" type="password" id="password2">
*</td>
</tr>
<tr>
<td height="30">性别:</td>
<td height="30"><input name="sex" type="text" id="sex"></td>
</tr>
<tr>
<td height="30">QQ:</td>
<td height="30"><input name="qq" type="text" id="qq"></td>
</tr>
<tr>
<td height="30">Mail:</td>
<td height="30"><input name="mail" type="text" id="mail"></td>
</tr>
<tr>
<td height="30">地址:</td>
<td height="30"><input name="add" type="text" id="add"></td>
</tr>
<tr>
<td>个人介绍</td>
<td><textarea name="personalinfo" cols="30" rows="6" id="personalinfo"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
5,(addnewdata.asp 新用户注册数据处理文件)
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>成功</title>
</head>
<body>
<%
ac=request.QueryString("ac")
msg="注册错误信息"
if request.Form("username")="" then
msg=msg&"<br>"&"用户名不能为空"
end if
if strcomp(cstr(request.Form("password")),cstr(request.Form("password2")))<>0 then
msg=msg&"<br>"&"两次密码输入不同"
end if

if len(request.Form("password"))<6 then
msg=msg&"<br>"&"密码太简单"
end if

if strcomp(msg,"注册错误信息")>0 then
response.Redirect("reg.asp?msg="&msg)
end if
if ac="adser" then
set rsc=server.createobject("adodb.recordset")
sql="select * from info where username='"&request.Form("username")&"'"
rsc.open sql,conn,1,1
ck=rsc("username")
set rsc=nothing
if ck<>"" then
msg=msg&"<br>"&"用户名被人注册"
response.Redirect("reg.asp?msg="&msg)
end if
dsql="select * from info where id is null"
set rs=server.createobject("adodb.recordset")
rs.open dsql,conn,1,3
rs.addnew
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs("ntime")=now
rs.update
set rs=nothing
%>
<center>
<a href="index.asp" target="_self">注册成功,点击登陆</a>
</center>
<%
end if
%>
</body>
</html>

6,(conn.asp 数据库连接文件)
<%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("userinfo.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="
'创建记录对象
set rs=server.createobject("adodb.recordset")
%>

7,(userinfo.mdb ACCESS 数据库)
在ACCESS中建一个表,然后在这个表中建立字段名称
表名:info

字段名称 数据类型
id 自动编号
username 文本
password 文本
sex 文本
quest 文本
qq 文本
mail 文本
personalinfo 文本
ntime 文本

⑵ 求asp中的登录注册的源码

分5个文件:
1:登录页面 login.htm
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登录</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="33%" height="64" id="table1">
<form name="form" action="go.asp" method="post"><tr>
<td>用户名:<input name="user"></td>
</tr>
<tr>
<td>密 码:<input type="password" name="pwd"></td>
</tr>
<tr>
<td><input name="sub" value="登录" type="submit"></td>
</tr></form>
</table>

</body>

</html>
------------------------
2.数据库连接文件 conn.asp
<%set rs=server.createobject("adodb.recordset")
conn = "driver={Microsoft Access Driver (*.mdb)};DBQ="&server.mappath("data.mdb")
%>
-------------------------

3:登录检测页面 go.asp
<!-- #include file="conn.asp" -->
<%
pwd=request.Form("pwd")
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&request.Form("user")&"'"
rs.open sql,conn,1,1
if rs.eof or rs.bof then'如果用户名不存在
response.Write"<script language=javascript>alert('请输入正确的用户名!');history.go(-1);</script>"
Response.End()
else
if rs("pwd")<>pwd then'如果密码不对
response.write "<script language=JavaScript>alert('密码有误!');history.back();</script>"
else
response.write("登录成功")'
end if
end if%>
-------------------------------
4。注册文件 add.asp
<!-- #include file="conn.asp" -->
<%
sql="select * from user where u_user='"&request.Form("user")&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.BOF or rs.EOF then
rs.addnew
rs("name")=request.Form("user")
rs("pwd")=request.Form("pwd")
rs.update
rs.close
set rs=nothing
response.Write ("注册成功!")
else
rs.close
set rs=nothing
response.write ("此用户已被注册")
end if
%>
4。注册页面 re.htm
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册</title>
</head>

<body>

<table border="0" cellpadding="0" cellspacing="0" width="33%" height="64" id="table1">
<form name="form" action="add.asp" method="post"><tr>
<td>用户名:<input name="user" size="23"></td>
</tr>
<tr>
<td>密 码:<input name="pwd" size="23" id="pwd"></td>
</tr>
<tr>
<td><input name="sub" value="注册" type="submit"></td>
</tr></form>
</table>
</body>
</html>
将这几个文件和数据库“data.mdb”放在同一目录内
数据库建一个USER表
含name pwd 两个字段 文本类型
运行login.htm测试登录
运行re.htm测试注册

⑶ 用户登录 asp+sql源码

数据库建立一个表admin 3个列:Username Passwd oskey(用户级别)
ODBC数据源创建一个sql的数据源与你建立的数据库连上。
conn.asp
<%
set conn=server.createobject("adodb.connection")
conn.connectionstring="DSN=ccsw;uid=sa;pwd=1234"
conn.open
%>
index.asp
<html>

<head>
<title>管理登录</title>
<link rel="stylesheet" href="style.CSS">
<style type="text/css">
<!--
.style1 {color: #9966FF}
.style2 {
font-size: 12pt;
font-weight: bold;
color: #9966FF;
}
.style3 {
font-size: 12pt;
color: #0033CC;
}
.style4 {color: #0000CC}
-->
</style>
</head>

<body>
<div align="center"><center>

<table border="0" cellspacing="1" width="90%">
<tr>
<td> <form method="post" action="chklogin.asp">
<table width="300" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#000000">
<tr bgcolor="#FFFFFF">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td height="30" colspan="2" align="right"><div align="center" class="style1 style3"><strong>管理登录</strong></div></td>
</tr>
<tr>
<td width="33%" align="right" height="30"><span class="style4">用户名:</span></td>
<td width="67%">
<input name="UserName" maxlength="20" class="smallInput" size="20">
</td>
</tr>
<tr>
<td width="33%" align="right" height="30"><span class="style4">密 码:</span></td>
<td width="67%">
<input type="password" name="Passwd" maxlength="16" class="smallInput"
size="20">
</td>
</tr>
<tr>
<td colspan="2" height="15"></td>
</tr>
</table>
</td>
</tr>
<tr align="center" bgcolor="#FFFFFF">
<td height="31" bgcolor="#9999FF">
<input type="submit" name="Submit" value="确定" class="buttonface">

<input type="reset" name="Submit2" value="重写" class="buttonface"></td>
</tr>
</table>
</form>
<p align="center">后台登录</td>
</tr>
</table>
</center></div>
</body>
</html>
检查用户界面:
<!--#include file=articleconn.asp-->
<%
dim rs
UserName1=request.form("UserName")'获得登录界面输入的用户名
Passwd1=request.form("PassWd")''获得登录界面输入的密码
set rs=server.CreateObject("ADODB.RecordSet")'建立数据库连接
rs.open "select * from admin where UserName='" & UserName1 & "' and passwd='"&passwd1&"'",conn,1 '查询该用户名和密码是否存在
if rs.eof or rs.bof then '当没有符合筛选结果时,则执行下面的句子
response.write "<script language=javascript>"
response.write "alert('用户或密码不对!');"
response.write "javascript:history.go(-1);"
response.write "</script>" '用javascript脚本提示用户
else '如果符合条件的时候
session("UserName")=RS("Username") '新建session,值等于表单传来的用户名
session("KEY")=rs("OSKEY")
response.write"<SCRIPT language=JavaScript>alert('登录成功');"
response.write"this.location.href='admin.asp';</SCRIPT>"
end if '结束if语句
%>

热点内容
怎么让电脑不存储临时文件 发布:2024-09-28 22:44:59 浏览:655
php中替换字符串 发布:2024-09-28 22:01:48 浏览:582
sql数据库的使用 发布:2024-09-28 22:01:41 浏览:627
你们的wifi密码多少 发布:2024-09-28 21:53:07 浏览:376
android访问服务器 发布:2024-09-28 21:48:46 浏览:734
安卓平板如何实现电脑双击 发布:2024-09-28 21:27:11 浏览:360
德育php 发布:2024-09-28 21:24:36 浏览:17
企业密信如何登录服务器ld 发布:2024-09-28 21:22:52 浏览:463
通过ip不能访问网站 发布:2024-09-28 21:21:47 浏览:523
c语言取整数部分 发布:2024-09-28 21:17:59 浏览:66