国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

asp!用戶注冊示例代碼

2019-11-02 14:23:49
字體:
來源:轉載
供稿:網友

 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" />

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临朐县| 天津市| 黔江区| 禹州市| 深州市| 新干县| 西畴县| 玛纳斯县| 陇西县| 新和县| 元阳县| 永靖县| 沁水县| 利津县| 黔江区| 微山县| 固始县| 翼城县| 双鸭山市| 鸡东县| 兴化市| 嘉荫县| 宜兰市| 九龙县| 太康县| 安阳市| 类乌齐县| 乃东县| 沧源| 珲春市| 赤壁市| 弥勒县| 龙南县| 华安县| 彭水| 桓台县| 商南县| 临颍县| 旺苍县| 兴文县| 志丹县|