当前位置:编程学习 > asp >>

asp access用户注册实例

本文章提供一款关于asp教程 access用户注册实例哦,页面只提供部份参考代码,我们提供这款实例完整源码下载,如果你喜欢可以免费下载本款源码哦。

<!--#include file="conn.asp" -->
<!--#include file ="procedure.asp"-->
<!--#include file="md5.asp" -->
<%
sub save()
 dim username,userpwd,pwd,name,email
 '读取从表单传递过来的用户名数据,trim函数去掉字符串的前导与后续空格
 username=trim(request.form("username"))
 userpwd=trim(request.form("userpwd"))
 pwd=trim(request.form("pwd"))
 name=trim(request.form("name"))
 email=trim(request.form("email"))
 '用户输入不完全
 if username="" or userpwd="" or pwd="" or name="" or email="" then
  '给出提示,返回注册页面。history.back()表示返回注册页面
  response.write "<script>alert('输入信息不完整!');history.back();</script>"
  response.end
 end if
 if userpwd<>pwd then   '两次输入的密码不相同
  '给出提示,并返回注册页面
  response.write "<script>alert('两次输入的密码不相同!');history.back();</script>"
  response.end
 end if
 'isvalidemail过程判断用户输入的邮件地址格式是否正确
 if not isvalidemail(email) then
  '邮件地址格式错误,则给出提示,并返回到注册页面
  response.write "<script>alert('邮件地址格式有误!');history.back();</script>"
  response.end
 end if
 '判断数据库教程中是否存在用户输入的用户名
 set hvrs=server.createobject("adodb.recordset")
 '从数据库中查找username列的值为username的记录
 sql="select * from user where username='" & username & "'"
 hvrs.open sql,conn,1,1
 if not (hvrs.eof and hvrs.bof) then   '存在满足条件的记录
  '用户名在数据库中存在,则给出提示,并返回注册页面
  response.write "<script>alert('该用户名已经存在!请重新填写……');history.back();</script>"
  response.end
 else   '不存在满足条件的记录
  '在数据库中插入一条新记录
  set rs=server.createobject("adodb.recordset")
  sql="select username,password,name,email from user"
  rs.open sql,conn,1,3
  rs.addnew
  rs("username")=username   '用户登录名
  rs("password")=md5(userpwd)   '用户登录密码
  rs("name")=name   '用户真实姓名
  rs("email")=email   '用户电子邮箱
  rs.update   '更新数据库
  rs.close
 end if
 hvrs.close
 set hvrs=nothing
end sub
%>
<html>
<head>
<link rel="stylesheet" href="images/styles.css教程" type="text/css">
<title>聊天室</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p align="center" style="margin-top:10">
 <font size="6">聊天室注册向导</font>
</p>
<hr>
<center>
<%
 if request.querystring("result")="successful" then
  call save()
  call show()
 else
  call main()
 end if
%>
</center>
<%sub main()%>
<center>
<form method="post" action="register.asp?result=successful" name=registerform>
<table border="0" width="625" cellspacing="1" height="80">
 <tr>
  <td width="472" colspan="2" height="17" align=center>
   <p align="center">
    <b>基本信息设置</b><br><br>
   </p>
  </td>
 </tr>
 <tr>
  <td width="126" height="8" bgcolor="#c0c0c0">
   <p align="center">
    <font color="#000000" size="2">用 户 帐 号:</font>
   </p>
  </td>
  <td width="485" height="8">
   <input name="username" size="32"  class="bk"> <font color="#ff0000">
   <font size="2">*</font></font><font color="#000000" size="2">请输入您需要注册的用户名</font>
  </td>
 </tr>
 <tr>
  <td width="126" height="8" bgcolor="#c0c0c0">
   <p align="center">
    <font color="#000000" size="2">用 户 密 码:</font>
   </p>
  </td>
  <td width="485" height="1">
   <p align="left">
    <input type="password" name="userpwd" size="32"  class="bk"> <font color="#ff0000">
    <font size="2">*</font></font><font color="#000000" size="2">用于登陆系统的身份验证</font>
   </p>
  </td>
 </tr>
 <tr>
  <td width="126" height="8" bgcolor="#c0c0c0">
   <p align="center">
    <font color="#000000" size="2">密 码 确 认:</font>
   </p>
  </td>
  <td width="485" height="25">
   <input type="password" name="pwd" size="32" class="bk"> <font color="#ff0000">
   <font size="2">*</font></font><font size="2">确认密码</font>
  </td>
 </tr>
 <tr>
  <td height="8" width="126" bgcolor="#c0c0c0">
   <p align="center">
    <font size="2">真 实 姓 名:</font>
   </p>
  </td>
  <td height="1" width="559">
   <input type="text" name="name" size="32" class="bk"> <font color="#ff0000">
   <font size="2">*</font></font><font size="2">请输入真实姓名</font>
  </td>
 </tr>
 <tr>
  <td height="8" width="126" bgcolor="#c0c0c0">
   <p align="center">
    <font size="2">电 子 邮 箱:</font>
   </p>
  </td>
  <td height="1" width="559">
   <input type="text" name="email" size="32" class="bk" style="ime-mode:disabled"> <font color="#ff0000">
   <font size="2">*</font></font><font size="2">请输入您的电子邮箱</font>
  </td>
 </tr>
 <tr>
  <td width="472" colspan="2" height="21">
   <p align="center">
   <p align="center">
   <input type="submit" value="提交" name="register" class="tips教程_bo">
  </td>
 </tr>
</table>
</form>
<%end sub%>
<%sub show()%>
<table border="0" width="71%" cellspacing="1" height="47">
 <tr>
  <td width="100%" height="21">
   <p align="center">
    <font color="#ff0000">
     <b>用户注册成功</b>
    </font>
   </p>
  </td>
 </tr>
 <tr>
  <td width="100%" height="18">
   <p align="center">
    <font color="#ffffff">您的信息设置已经成功,进入聊天室请点击“完成”</font>
   </p>
   <p align="center">[ <a href="index.asp"><b>完成</b></a> ]
  </td>
 </tr>
</table>
<%end sub%>
</body>
</html>
<%
set rs=nothing
conn.close
set conn=nothing
%>

下载本款实例源码

http://down.zzzyk.com/down/code/asp/2010/1024/21402.html

补充:asp教程,数据库相关 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,