国产探花免费观看_亚洲丰满少妇自慰呻吟_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" />

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌拉特前旗| 清流县| 青川县| 敦煌市| 胶州市| 五家渠市| 崇明县| 塔城市| 武冈市| 卢龙县| 灌南县| 井研县| 雅江县| 自贡市| 巴东县| 清流县| 沙河市| 梁河县| 司法| 伊宁市| 株洲市| 漯河市| 卓尼县| 颍上县| 吉安市| 东光县| 霍城县| 乌什县| 扎赉特旗| 辰溪县| 分宜县| 商河县| 余江县| 罗城| 凭祥市| 静海县| 泰来县| 阳新县| 罗田县| 凤山县| 塔城市|