asp access使用者註冊執行個體

來源:互聯網
上載者:User

<!--#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">&nbsp;<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">&nbsp;<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">&nbsp;<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">&nbsp;<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">&nbsp;<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.111cn.net/down/code/asp/2010/1024/21402.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.