手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp用户注册示例代码
asp用户注册示例代码
摘要:asp用户注册示例代码:数据库设计:表名:userinfo字段名类型/长度说明id自动编号用户IDusernametext/16用户名pas...

asp用户注册示例代码:

数据库设计:
表名:userinfo
字段名 类型/长度 说明
id 自动编号 用户ID
username text/16 用户名
password text/32 MD5 32位加密
addtime 时间日期 注册时间
代码如下:
<%
'asp教程用户注册示例
'
dim db,conn,myconn
db="asporgcn.mdb" '数据库文件相对路径
Set Conn = Server.CreateObject("ADODB.Connection") '创建对象实例
myconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
Conn.Open MyConn
if request("submit")<>"" then '用户点击提交按钮
username=request("username")
password=request("password")
password2=request("password2")
if password<>password2 then
response.write("<script>alert('两次输入的密码不对');window.history.back();</script>")
response.end() '结束运行
end if
set rs=server.CreateObject("adodb.recordset")
sql="select count(0) from userinfo where username='"&username&"'"
rs.open sql,conn,1,1
if rs(0)>0 then '判断用户名是否已经注册
response.write("<script>alert('用户名已经存在');window.history.back();</script>")
response.end() '结束运行
else
'response.write "insert into userinfo(username,password) values('"&username&"','"&password&"')"
conn.execute("insert into userinfo([username],[password]) values('"&username&"','"&password&"')") '添加到数据库注册完成,password是ACCESS中的保留关键字。保留关键字用[]括起来就不会出错。
response.write("<script>alert('注册成功!');window.history.back();</script>")
end if
rs.close
set rs=nothing '使用完RS后一定要记得关闭与释放,否则占用服务器资源,在ASP程序面试时,这一点一定要记住
end if
conn.close '关闭连接,
set conn=nothing '释放内存 这两句很重要,不然会占用大量服务器资源。
%>
<html>
<head>
<title>用户注册案例</title>
<META content="中国ASP网编写的用户注册案例教程。" name=description>
</head>
<body>
<form id="form1" name="form1" method="post" action="index.asp">
<table width="400" border="1">
<tr>
<td>用户名:</td>
<td><label>
<input name="username" type="text" id="username" size="16" maxlength="16" />
</label></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="password" type="password" id="password" size="16" maxlength="16" /></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input name="password2" type="password" id="password2" size="16" maxlength="16" /></td>
</tr>
<tr>
<td colspan="2"><label>
<input type="submit" name="Submit" value="提交" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

【asp用户注册示例代码】相关文章:

asp.net验证码图片生成示例

html+ashx 表单提交示例

asp.net 多字段模糊查询代码

asp.net(c#) RSS功能实现代码

asp.net下中文验证码,免费开源代码

ASP.NET Dictionary 的基本用法示例介绍

asp.net 简易生成注册码(数字+大小写字母)

.Net 文本框实现内容提示的实例代码

asp.net自定义控件代码学习笔记

asp.net 获取图片高度和宽度实例代码

精品推荐
分类导航