ASP注冊登陸實(shí)例代碼
數(shù)據(jù)庫位置:data/data.mdb
數(shù)據(jù)庫表:user
id name pwd wenti daan
conn.asp
<%
db="data/data.mdb" '數(shù)據(jù)庫存放目錄
on error resume next
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath(db)
if err then
err.clear
set conn = Nothing
response.write "數(shù)據(jù)庫連接出錯,請檢查conn.asp中的連接字符串。"
response.end
end if
function CloseDB
Conn.Close
set Conn=Nothing
End Function
%>
<%
dim badword
badword="'|and|select|update|chr|delete|%20from|;|insert|mid|master.|set|chr(37)|="
if request.QueryString<>"" then
chk=split(badword,"|")
for each query_name in request.querystring
for i=0 to ubound(chk)
if instr(lcase(request.querystring(query_name)),chk(i))<>0 then
response.write "<script language=javascript>alert('傳參錯誤!參數(shù) "&query_name&" 的值中包含非法字符串!\n\n');location='"&request.ServerVariables ("HTTP_REFERER")&"'</Script>"
response.end
end if
next
next
end if
%>
reg.asp
<!--#i nclude file="conn.asp"-->
<%
if request("action")="reg" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from user where name='"&trim(request("name"))&"'",conn,1,1
if rs.recordcount>0 then
response.write "<Script language='JavaScript'>window.alert('您輸入的用戶名已存在,請返回重新輸入!');history.back(-1);</Script>"
response.End()
end if
sql="select * from user"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
rs.addnew
rs("name")=trim(request.Form("name"))
rs("pwd")=trim(request.Form("pwd"))
rs("wenti")=trim(request.Form("wenti"))
rs("daan")=trim(request.Form("daan"))
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript> alert('注冊成功,點(diǎn)擊確定立即登錄!');location.replace('login.asp');</script>"
response.end
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>用戶注冊
<form name="form1" method="post" action="?action=reg" onsubmit="return chkform(this)">
<table width="347" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="142">用戶名</td>
<td width="179"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>密碼</td>
<td><input name="pwd" type="password" id="pwd"></td>
</tr>
<tr>
<td>密碼提示問題</td>
<td><input name="wenti" type="text" id="wenti"></td>
</tr>
<tr>
<td>密碼提示答案</td>
<td><input name="daan" type="text" id="daan"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="注冊">
<input type="reset" name="Submit" value="重置"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
top.asp
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><a href="/"";index.asp">首頁</a>
<%
if Session("name")="" then
%>
<a href="/"";reg.asp">注冊</a> <a href="/"";login.asp">登陸</a>
<a href="/"";pwd.asp">忘記密碼?</a> <%
else
%>
歡迎您<%=Session("name")%>, <a href="/"";loginout.asp">注銷登陸</a>
<%
end if
%>
<a href="/"";jiami.asp">加密頁</a></td>
</tr>
</table>
<br>
login.asp
<!--#i nclude file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>
用戶登陸
<%
if Session("name")="" then
%>
<form name="form1" method="post" action="loginok.asp?action=login" onsubmit="return chkform(this)">
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td width="116">用戶名</td>
<td width="116"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td>密碼</td>
<td><input name="pwd" type="password" id="pwd"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="登陸">
<input type="reset" name="Submit" value="重置"></td>
</tr>
</table>
</form>
<%
else
%>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td width="303"><%=Session("name")%>,您已經(jīng)成功登陸</td>
</tr>
</table>
<%
end if
%>
</td>
</tr>
</table>
</body>
</html>
loginok.asp
<!--#i nclude file="conn.asp"-->
<%
Session.TimeOut=30
if request("action")="login" then
name=trim(request.form("name"))
pwd=trim(request.form("pwd"))
if name="" or pwd="" then
Response.Redirect ("login.asp")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&name&"'and pwd='"&pwd&"'"
rs.open sql,conn,1,1
if not rs.eof then
session("name")=name
response.redirect"edit.asp"
else
response.redirect"Error.asp"
response.end
end if
end if
%>
loginout.asp
<%
session("name")=""
response.write "<script language=javascript> alert('退出登陸成功!');location.href('index.asp');</script>"
response.end
%>
pwd.asp
<!--#i nclude file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><p>找回密碼</p>
<form name="form1" method="post" action="pwd2.asp?action=pwd">
<table width="398" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="130">請輸入用戶名</td>
<td width="168"><input name="name" type="text" id="name"></td>
<td width="62"><input type="submit" name="Submit" value="查詢"></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
pwd2.asp
<!--#i nclude file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>
找回密碼
<%
name=trim(request.form("name"))
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&name&"'"
rs.open sql,conn,1,1
if not rs.eof then
%>
<form name="form1" method="post" action="pwd3.asp">
<table width="398" border="1" cellpadding="5" cellspacing="0">
<tr>
<td><%=rs("name")%></td>
<td> </td>
<td><input name="name" type="hidden" id="name" value="<%=rs("name")%>"></td>
</tr>
<tr>
<td width="130">密碼提示問題</td>
<td width="168"><%=rs("wenti")%>
</td>
<td width="62"> </td>
</tr>
<tr>
<td>密碼提示答案</td>
<td><input name="daan" type="text" id="daan"></td>
<td><input type="submit" name="Submit" value="查詢"></td>
</tr>
</table>
</form>
<% else
%>
<table width="413" border="1" cellpadding="5" cellspacing="0">
<tr>
< td>你輸入的用戶名不存在,請<a href="/"";javascript:history.back()">返回</a>重新輸入,或者<a href="/"";reg.asp">注冊</a></td>
</tr>
</table>
<%end if
%>
</td>
</tr>
</table>
</body>
</html>
pwd3.asp
<!--#i nclude file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>
找回密碼
<%
name=trim(request.form("name"))
daan=trim(request.form("daan"))
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&name&"' and daan='"&daan&"'"
rs.open sql,conn,1,1
if not rs.eof then
%>
<table width="398" border="1" cellpadding="5" cellspacing="0">
<tr>
<td width="130"><%=rs("name")%>,您的密碼</td>
<td><%=rs("pwd")%>
</td>
</tr>
</table>
<% else
%>
<table width="413" border="1" cellpadding="5" cellspacing="0">
<tr>
<td>你輸入的密碼提示答案不正確,請<a href="/"";javascript:history.back()">返回</a>重新輸入</td>
</tr>
</table>
<%end if
%>
</td>
</tr>
</table>
</body>
</html>
error.asp
<!--#i nclude file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>登陸失敗,請檢查用戶名和密碼是否正確 <a href="/"";login.asp">返回</a></td>
</tr>
</table>
</body>
</html>
edit.asp
<!--#i nclude file="conn.asp"-->
<%
if request("action")="edit" then
name=session("name")
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&name&"'"
rs.open sql,conn,3,2
rs("pwd")=trim(request.Form("pwd"))
rs("daan")=trim(request.Form("daan"))
rs.update
rs.close
set rs=nothing
response.write "<script language=javascript>alert('編輯成功!');location.href('edit.asp');</script>"
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標(biāo)題文檔</title>
</head>
<body><!--#i nclude file="top.asp"-->
<table width="90%" border="1" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><p>修改資料</p>
<p>
<%
if Session("name")="" then
%>
對不起你還沒有登陸,請<a href="/"";login.asp">登陸</a>或者<a href="/"";reg.asp">注冊</a>
<%
else
%>
<%
name=session("name")
set rs=server.createobject("adodb.recordset")
sql="select * from user where name='"&name&"'"
rs.open sql,conn,1,1
%>
</p>
<form action="?action=edit" method="post" name="form" id="form">
<table border="1" cellpadding="5">
<tr>
<td>用戶名</td>
<td><%=rs("name")%></td>
</tr>
<tr>
<td>密碼</td>
<td><input name="pwd" type="text" id="pwd" value="<%=rs("pwd")%>"></td>
</tr>
<tr>
<td>密碼提示問題</td>
<td><%=rs("wenti")%></td>
</tr>
<tr>
<td>密碼提示答案</td>
<td><input name="daan" type="text" id="daan" value="<%=rs("daan")%>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="修改">
<input type="reset" name="Submit" value="重置"></td>
</tr>
</table>
</form>
<p> <%
end if
%>
</p></td>
</tr>
</table>
</body>
</html>
- 用Net User命令恢復(fù)系統(tǒng)登陸用戶密碼
- 解決最近Hotmail無法登陸,hotmail不能登陸的最新解決方法總結(jié)
- qq防止別人登陸如何禁止別人登陸qq
- 用戶"sa"登陸失敗 SQLServer 錯誤18456的解決方法
- 一個簡單的網(wǎng)頁密碼登陸php代碼
- Android仿QQ登陸窗口實(shí)現(xiàn)原理
- python模擬新浪微博登陸功能(新浪微博爬蟲)
- PHP登陸后跳轉(zhuǎn)到登陸前頁面實(shí)現(xiàn)思路及代碼
- JAVA實(shí)現(xiàn)簡單系統(tǒng)登陸注冊模塊
- ASP 連接Access數(shù)據(jù)庫的登陸系統(tǒng)
相關(guān)文章
asp 標(biāo)記字符串中指定字符變色不區(qū)分大小寫
今天遇到這種問題,單純的使用replace函數(shù)不行,他會改變原有的字符串的大小寫,在網(wǎng)上找到相關(guān)的代碼,自己備份下2013-04-04ASP中字符與數(shù)字內(nèi)置操作函數(shù)整理
在ASP中,預(yù)定義了許多函數(shù),可以幫助我們簡化代碼、提高開發(fā)效率,本文將介紹一些常用的ASP字符與數(shù)字內(nèi)置操作函數(shù),以便開發(fā)人員更加方便、快速地創(chuàng)建 Web 應(yīng)用程序,2023-12-12ASP操作Excel相關(guān)技術(shù)總結(jié)
ASP操作Excel相關(guān)技術(shù)總結(jié)...2007-05-05ASP備份SQL Server數(shù)據(jù)庫改進(jìn)版
改進(jìn)的ASP備份SQL Server數(shù)據(jù)庫,網(wǎng)上原理的不是很好,需要的朋友可以參考下。2011-02-02