asp用戶注冊示例代碼
      來源:易賢網(wǎng) 閱讀:838 次 日期:2014-10-13 10:26:28
      溫馨提示:易賢網(wǎng)小編為您整理了“asp用戶注冊示例代碼”,方便廣大網(wǎng)友查閱!

      asp用戶注冊示例代碼:

      數(shù)據(jù)庫設(shè)計(jì):

      表名:userinfo

      字段名 類型/長度 說明

      id 自動(dòng)編號(hào) 用戶ID

      username text/16 用戶名

      password text/32 MD5 32位加密

      addtime 時(shí)間日期 注冊時(shí)間

      代碼如下:

      <%

      'asp教程用戶注冊示例

      'http://www.asp.org.cn

      dim db,conn,myconn

      db="asporgcn.mdb" '數(shù)據(jù)庫文件相對(duì)路徑

      Set Conn = Server.CreateObject("ADODB.Connection") '創(chuàng)建對(duì)象實(shí)例

      myconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")

      Conn.Open MyConn

      if request("submit")<>"" then '用戶點(diǎn)擊提交按鈕

      username=request("username")

      password=request("password")

      password2=request("password2")

      if password<>password2 then

      response.write("<script>alert('兩次輸入的密碼不對(duì)');window.history.back();</script>")

      response.end() '結(jié)束運(yùn)行

      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 '判斷用戶名是否已經(jīng)注冊

      response.write("<script>alert('用戶名已經(jīng)存在');window.history.back();</script>")

      response.end() '結(jié)束運(yùn)行

      else

      'response.write "insert into userinfo(username,password) values('"&username&"','"&password&"')"

      conn.execute("insert into userinfo([username],[password]) values('"&username&"','"&password&"')") '添加到數(shù)據(jù)庫注冊完成,password是ACCESS中的保留關(guān)鍵字。保留關(guān)鍵字用[]括起來就不會(huì)出錯(cuò)。

      response.write("<script>alert('注冊成功!');window.history.back();</script>")

      end if

      rs.close

      set rs=nothing '使用完RS后一定要記得關(guān)閉與釋放,否則占用服務(wù)器資源,在ASP程序面試時(shí),這一點(diǎn)一定要記住

      end if

      conn.close '關(guān)閉連接,

      set conn=nothing '釋放內(nèi)存 這兩句很重要,不然會(huì)占用大量服務(wù)器資源。

      %>

      <html>

      <head>

      <title>用戶注冊案例</title>

      <META content="中國ASP網(wǎng)編寫的用戶注冊案例教程。

      </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>確認(rèn)密碼:</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>

      更多信息請查看IT技術(shù)專欄

      更多信息請查看網(wǎng)絡(luò)編程
      易賢網(wǎng)手機(jī)網(wǎng)站地址:asp用戶注冊示例代碼
      由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

      2026上岸·考公考編培訓(xùn)報(bào)班

      • 報(bào)班類型
      • 姓名
      • 手機(jī)號(hào)
      • 驗(yàn)證碼
      關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
      工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
      云南網(wǎng)警備案專用圖標(biāo)
      聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
      咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
      云南網(wǎng)警報(bào)警專用圖標(biāo)