文章导航PC6首页软件下载单机游戏安卓资源苹果资源

pc软件新闻网络操作系统办公工具编程服务器软件评测

安卓新闻资讯应用教程刷机教程安卓游戏攻略tv资讯深度阅读综合安卓评测

苹果ios资讯苹果手机越狱备份教程美化教程ios软件教程mac教程

单机游戏角色扮演即时战略动作射击棋牌游戏体育竞技模拟经营其它游戏游戏工具

网游cf活动dnf活动lol周免英雄lol礼包

手游最新动态手游评测手游活动新游预告手游问答

您的位置:首页技术开发ASP 学院 → asp用户注册示例代码

asp用户注册示例代码

时间:2010/2/21 18:05:00来源:本站整理作者:我要评论(0)

asp用户注册示例代码:

数据库设计:
表名:userinfo
字段名 类型/长度 说明
id 自动编号 用户ID
username text/16 用户名
password text/32 MD5 32位加密
addtime 时间日期 注册时间
代码如下:
<%
'asp教程用户注册示例
'http://www.asp.org.cn
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网编写的用户注册案例教程。http://www.asp.org.cn" 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>

相关阅读 Windows错误代码大全 Windows错误代码查询excel数字变成代码怎么办zepeto怎么看代码lol源代码乐芙兰怎么领取 lol源代码乐芙兰领取条件奇迹暖暖危险代码虚拟之镰怎么搭配 危险代码虚拟之镰高分搭配推荐myeclipse怎么显示代码行数 myeclipse显示代码行数设置方法噬血代码特典奖励及PS4各版本区别一览 噬血代码预购奖励是什么噬血代码多人模式介绍 噬血代码多人模式怎么玩

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 127.0.0.1 需要输入用Microsoft JET Databa ASP木马密码加密的破解方法Asp中文件上传,fso方法大全js报错 抛出例外解决方法-适用于ecshop 调用127.0.0.1 需要输入用户名密码的解决方法

人气排行 教你如何用ASP生成HTML静态网页127.0.0.1 需要输入用户名密码的解决方法编写简单ASP代码测试WEB服务器环境asp用户登录模块实例代码ASP保存远程文件到本地(实用版)js报错 抛出例外解决方法-适用于ecshop 调用如何调试ASP的环境ASP.NET中MVC框架模式方法如何实现分享