asp代码注册登陆代码.docx
《asp代码注册登陆代码.docx》由会员分享,可在线阅读,更多相关《asp代码注册登陆代码.docx(10页珍藏版)》请在冰点文库上搜索。
asp代码注册登陆代码
asp代码-注册登陆代码
conn.asp
<%
db="data/data.mdb"'数据库存放目录
onerrorresumenext
setconn=server.createobject("adodb.connection")
conn.open"driver={microsoftaccessdriver(*.mdb)};dbq="&server.mappath(db)
iferrthen
err.clear
setconn=Nothing
response.write"数据库连接出错,请检查conn.asp中的连接字符串。
"
response.end
endif
CloseDB
Conn.Close
setConn=Nothing
End
%>
<%
dimbadword
badword="'|and|select|update|chr|delete|%20from|;|insert|mid|master.|set|chr(37)|="
ifrequest.QueryString<>""then
chk=split(badword,"|")
foreachquery_nameinrequest.querystring
fori=0toubound(chk)
ifinstr(lcase(request.querystring(query_name)),chk(i))<>0then
response.write"alert('传参错误!
参数"&query_name&"的值中包含非法字符串!
\n\n');location='"&request.ServerVariables("HTTP_REFERER")&"'>"
response.end
endif
next
next
endif
%>
reg.asp
--#includefile="conn.asp"-->
<%
ifrequest("action")="reg"then
setrs=server.CreateObject("adodb.recordset")
rs.open"select*fromuserwherename='"&trim(request("name"))&"'",conn,1,1
ifrs.recordcount>0then
response.write"alert('您输入的用户名已存在,请返回重新输入!
');history.back(-1);>"
response.End()
endif
sql="select*fromuser"
setrs=server.createobject("adodb.recordset")
rs.opensql,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
setrs=nothing
response.write"alert('注册成功,点击确定立即登录!
');location.replace('login.asp');>"
response.end
endif
%>
无标题文档--#includefile="top.asp"-->
用户注册 action=reg"onsubmit="returnchkform(this)">
用户名
|
|
密码 | |
密码提示问题 | |
密码提示答案 | |
|
top.asp
首页 <% ifSession("name")=""then %> 注册登陆 忘记密码? <% else %> 欢迎您<%=Session("name")%>,注销登陆 <% endif %> 加密页 |
login.asp
--#includefile="conn.asp"-->
无标题文档--#includefile="top.asp"-->
用户登陆 <% ifSession("name")=""then %> action=login"onsubmit="returnchkform(this)">
用户名
|
|
密码 | |
|
<%
else
%>
<%=Session("name")%>,您已经成功登陆
|
<%
endif
%>
loginok.asp
--#includefile="conn.asp"-->
<%
Session.TimeOut=30
ifrequest("action")="login"then
name=trim(request.form("name"))
pwd=trim(request.form("pwd"))
ifname=""orpwd=""then
Response.Redirect("login.asp")
endif
setrs=server.createobject("adodb.recordset")
sql="select*fromuserwherename='"&name&"'andpwd='"&pwd&"'"
rs.opensql,conn,1,1
ifnotrs.eofthen
session("name")=name
response.redirect"edit.asp"
else
response.redirect"Error.asp"
response.end
endif
endif
%>
loginout.asp
<%
session("name")=""
response.write"alert('退出登陆成功!
');location.href('index.asp');>"
response.end
%>
pwd.asp
--#includefile="conn.asp"-->
无标题文档--#includefile="top.asp"-->
找回密码 action=pwd">
请输入用户名
|
|
pwd2.asp
--#includefile="conn.asp"-->
无标题文档--#includefile="top.asp"-->
找回密码 <% name=trim(request.form("name")) setrs=server.createobject("adodb.recordset") sql="select*fromuserwherename='"&name&"'" rs.opensql,conn,1,1 ifnotrs.eofthen %>
|
<%=rs("name")%> | | "> |
密码提示问题
<%=rs("wenti")%>
|
密码提示答案 | | |
<%else
%>
你输入的用户名不存在,请 history.back()">返回重新输入,或者注册 |
<%endif
%>
pwd3.asp
--#includefile="conn.asp"-->
无标题文档--#includefile="top.asp"-->
找回密码 <% name=trim(request.form("name")) daan=trim(request.form("daan")) setrs=server.createobject("adodb.recordset") sql="select*fromuserwherename='"&name&"'anddaan='"&daan&"'" rs.opensql,conn,1,1 ifnotrs.eofthen %>
|
<%=rs("name")%>,您的密码
<%=rs("pwd")%> |
<%else
%>
你输入的密码提示答案不正确,请 history.back()">返回重新输入 |
<%endif
%>
error.asp
--#includefile="conn.asp"-->
无标题文档--#includefile="top.asp"-->
登陆失败,请检查用户名和密码是否正确返回 |
edit.asp
--#includefile="conn.asp"-->
<%
ifrequest("action")="edit"then
name=session("name")
setrs=server.createobject("adodb.recordset")
sql="select*fromuserwherename='"&name&"'"
rs.opensql,conn,3,2
rs("pwd")=trim(request.Form("pwd"))
rs("daan")=trim(request.Form("daan"))
rs.update
rs.close
setrs=nothing
response.write"alert('编辑成功!
');location.href('edit.asp');>"
endif
%>
无标题文档--#includefile="top.asp"-->
修改资料 <% ifSession("name")=""then %> 对不起你还没有登陆,请登陆或者注册 <% else %> <% name=session("name") setrs=server.createobject("adodb.recordset") sql="select*fromuserwherename='"&name&"'" rs.opensql,conn,1,1 %> action=edit"method="post"name="form"id="form">
用户名 | <%=rs("name")%> |
|
密码 | "> |
密码提示问题 | <%=rs("wenti")%> |
密码提示答案 | "> |
|
|
<%
endif
%>