asp完整登陆代码 <% option explicit 强制浏览器重新访问服务器下载页面 而不是从缓存读取页面 Response Buffer = True Response Expires = Response ExpiresAbsolute = Now() Response Expires = Response CacheControl = "no cache" 主要是使随机出现的图片数字随机 %><! #include file="inc/config asp" ><!DOCTYPE HTML PUBLIC " //W C//DTD HTML Transitional//EN"><HTML><HEAD><TITLE><%=rs_config("c_incname")%>管理员登录</TITLE><meta equiv="Content Type" content="text/charset=gb "><LINK href="inc/login css" rel=stylesheet type=text/css><base target="main"><style type=text/css><! style {font size: pt} ></style><SCRIPT language=JavaScript><! function frmSubmit() {
if (theForm name value == "") { alert("请输入用户名") theForm name focus() return false } if (theForm pass value == "") { alert("请输入密码") theForm pass focus() return false} if (theForm safecode value == "") { alert("请输入校验码") theForm safecode focus() return false}
return true} // ></SCRIPT><link rel="icon" href="/favicon ico" type=image/x icon /><link rel="shortcut icon" href="/favicon ico" type=image/x icon /><META equiv=Content Type content="text/charset=gb "><LINK href="images/WEI css" type=text/css rel=stylesheet><META content="Microsoft FrontPage " name=GENERATOR></HEAD><BODY bgColor=#ffffff><BR><br><br><br><br><BR><TABLE align=center cellSpacing= cellPadding= width= border= bordercolor="# "><TBODY><TR><TD width= ><TABLE align=center cellSpacing= cellPadding= width= border= bordercolor="# "><TBODY><TR><TD vAlign=top width= height= ><FORM action=logincheck asp method=POST target="_top"><table width= border= align=center cellpadding=" " cellspacing=" "> <tr> <td colspan=" "><img src=images/Admin_Login gif width= height= ></td> </tr> <tr> <td width= valign="top" background="Images/Admin_Login gif"><table width= border= cellspacing=" " cellpadding=" "> <tr> <td height= colspan=" ">&nbsp</td> </tr> <tr> <td width= rowspan=" ">&nbsp</td> <td width= ><font color="# BC ">用户名称 </font></td> <td width= rowspan=" ">&nbsp</td> <td width= ><font color="# BC ">用户密码 </font></td> <td width= >&nbsp</td> <td width= ><font color="# BC ">验证码 <b><font color=#ff ><IMG src=inc/Code asp width= height= align=ab *** iddle></font></b></font></td> </tr> <tr> <td><input name=name id="name" size= ></td> <td><input name=pass type=password id="pass" size= ></td> <td>&nbsp</td> <td><INPUT name=safecode type=text id="safecode" size= ></td> </tr> </table></td> <td> <input type=image name=Submit src=Images/Admin_Login gif ></td> </tr></table></FORM></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>
下面是asp处理文件 <%@LANGUAGE="VBSCRIPT" CODEPAGE=" "%><meta equiv="Content Type" content="text/charset=gb ">
<! #include file="conn asp" ><! #include file="md asp" >
<% function CPost() dim server_v server_v cpost=false server_v =Cstr(Request ServerVariables("HTTP_REFERER")) server_v =Cstr(Request ServerVariables("SERVER_NAME")) if mid(server_v len(server_v ))<>server_v then cpost=false else cpost=true End if End function session Timeout= if CPost=false then emsg="请不要从其它站点提交表" response Redirect("login asp?emsg=请不要从其它站点提交表") Response End() End if
dim aname apass FoundErr ErrMsg FoundErr=False aname=replace(trim(request("name")) " " "") apass=replace(trim(request("pass")) " " "") safecode=replace(trim(Request("safecode")) " " "") if len(aname)>or len(aname)< then FoundErr=True ErrMsg=ErrMsg&"用户名不对!nn" End if
if len(apass)>or len(apass)< then FoundErr=True ErrMsg=ErrMsg&"用户密码不对!nn" End if if Safecode="" then FoundErr=True ErrMsg=ErrMsg &"验证码不能为空!nn" end if if Session("Admin_GetCode")="" then FoundErr=True ErrMsg=ErrMsg &"你登录时间过长 请重新返回登录页面进行登录 nn" end if if Safecode<>CStr(Session("Admin_GetCode")) then FoundErr=True ErrMsg=ErrMsg &"您输入的确认码和系统产生的不一致 请重新输入 nn" end if if FoundErr=True then Call LoginError(ErrMsg) Conn close Set Conn=Nothing else
apass=md (apass) dim sql rs sql="select a_name a_pass a_flag from admin where a_name= "&aname&" and a_pass= "&apass&" " set rs=server createobject("adodb recordset") rs open sql conn if rs BOF and rs EOF then ErrMsg="用户名或是密码错误!" Call LoginError(ErrMsg) rs close set rs=Nothing conn close set conn=Nothing response End elseif Not(rs BOF or rs EOF) then session("aname")=rs("a_name") session("admin_flag")="into" session("admin_sys")=rs("a_flag") response Redirect("useradmin asp") rs close set rs=Nothing conn close set conn=Nothing response End End if end if
Sub LoginError(EMsg) response write "<script language= javascript >" &chr( ) response write "alert( "&EMsg&" )" &Chr( ) response write "window document location "&Chr( ) response write "</script>" &Chr( ) Response End End Sub
lishixinzhi/Article/program/net/201311/143571,(index.asp 用户登陆页面)
<!-- #include file="conn.asp" -->
<!-- blog.soowooo.cn 悠悠长假期 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>会员</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体
font-size: 14px
}
-->
</style>
</head>
<body>
<center>
<p>会员注册系统</p>
<form name="form1" method="post" action="login.asp">
<table width="34%" border="0">
<tr>
<td width="33%" height="30">用户名:</td>
<td width="67%" height="30"><input name="username" type="text" id="username" size="15"></td>
</tr>
<tr>
<td height="30">密 码:</td>
<td height="30"><input name="password" type="password" id="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="确定">
<input type="reset" name="Submit" value="重置"></td>
</tr>
<tr>
<td colspan="2"><a href="reg.asp" target="_self">注册</a></td>
</tr>
</table>
</form>
</center>
</body>
</html>
2,(login.asp 用户数据处理文件)
<!-- #include file="conn.asp" -->
<%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"&request.Form("username")&"' and password='"&request.Form("password")&"'"
rsc.open sqlc,conn,1,1
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
set rsc=nothing
response.Redirect("change.asp")
'如果用户不存在,session("username")为空
%>
3,(change.asp 用户信息修改页面)
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>修改</title>
<style type="text/css">
<!--
body,td,th {
font-size: 14px
}
-->
</style></head>
<center>
<body>
<br>
<%
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"&session("username")&"' and password='"&session("password")&"'"
rsc.open sqlc,conn,1,1
nr=rsc("password")
username=rsc("username")
password=rsc("password")
sex=rsc("sex")
qq=rsc("qq")
mail=rsc("mail")
add=rsc("add")
personalinfo=rsc("personalinfo")
vv=rsc("ntime")
set rsc=nothing
if nr="" then
response.Redirect("index.asp")
end if
if strcomp(nr,request.Form("password"))=0 then
response.Write("欢迎你!"&request.Form("username"))
response.Write("你是在"&vv&"注册的")
session("username")=request.Form("username")
end if
if session("username")="" then
response.Redirect("index.asp")
end if
%>
<form name="form1" method="post" action="change.asp?ac=ch">
<table width="39%" height="105" border="0" >
<tr>
<td width="27%" height="30">用户名:</td>
<td width="73%" height="30"><input name="username" type="text" id="username" value="<%=username%>">
*</td>
</tr>
<tr>
<td height="30">密 码:</td>
<td height="30"><input name="password" type="text" id="password" value="<%=password%>">
*</td>
</tr>
<tr>
<td height="30">性 别:</td>
<td height="30"><input name="sex" type="text" id="sex" value="<%=sex%>"></td>
</tr>
<tr>
<td height="30">QQ:</td>
<td height="30"><input name="qq" type="text" id="qq" value="<%=qq%>"></td>
</tr>
<tr>
<td height="30">Mail:</td>
<td height="30"><input name="mail" type="text" id="mail" value="<%=mail%>"></td>
</tr>
<tr>
<td height="30">地 址:</td>
<td height="30"><input name="add" type="text" id="add" value="<%=add%>"></td>
</tr>
<tr>
<td>介绍</td>
<td><textarea name="personalinfo" cols="30" rows="6" id="personalinfo"><%=personalinfo%></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="修改">
<a href="change.asp?se=y" target="_self">退出系统</a></td>
<% if strcomp(request.QueryString("se"),"y")=0 then
session("username")=""
response.Redirect("index.asp")
end if
%>
</tr>
</table>
</form>
<%
if strcomp(request.QueryString("ac"),"ch")=0 then
set rs=server.createobject("adodb.recordset")
sql="select * from info where username='"&session("username")&"'"
rs.open sql,conn,1,3
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs.update
set rs=nothing
response.Write("修改完成!")
end if
%>
</body>
</center>
</html>
4,(reg.asp 新用户注册页面)
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>用户注册</title>
<style type="text/css">
<!--
body,td,th {
font-family: 宋体
font-size: 14px
}
-->
</style>
</head>
<body>
<center>
用户注册<br>
<%
=request.QueryString("msg")
%>
<form name="form1" method="post" action="addnewdata.asp?ac=adduser">
<table width="39%" height="105" border="0" >
<tr>
<td width="27%" height="30">用户名:</td>
<td width="73%" height="30"><input name="username" type="text" id="username">
*</td>
</tr>
<tr>
<td height="30">密码:</td>
<td height="30"><input name="password" type="password" id="password">
*</td>
</tr>
<tr>
<td height="30">确定密码:</td>
<td height="30"><input name="password2" type="password" id="password2">
*</td>
</tr>
<tr>
<td height="30">性别:</td>
<td height="30"><input name="sex" type="text" id="sex"></td>
</tr>
<tr>
<td height="30">QQ:</td>
<td height="30"><input name="qq" type="text" id="qq"></td>
</tr>
<tr>
<td height="30">Mail:</td>
<td height="30"><input name="mail" type="text" id="mail"></td>
</tr>
<tr>
<td height="30">地址:</td>
<td height="30"><input name="add" type="text" id="add"></td>
</tr>
<tr>
<td>个人介绍</td>
<td><textarea name="personalinfo" cols="30" rows="6" id="personalinfo"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="提交"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
5,(addnewdata.asp 新用户注册数据处理文件)
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>成功</title>
</head>
<body>
<%
ac=request.QueryString("ac")
msg="注册错误信息"
if request.Form("username")="" then
msg=msg&"<br>"&"用户名不能为空"
end if
if strcomp(cstr(request.Form("password")),cstr(request.Form("password2")))<>0 then
msg=msg&"<br>"&"两次密码输入不同"
end if
if len(request.Form("password"))<6 then
msg=msg&"<br>"&"密码太简单"
end if
if strcomp(msg,"注册错误信息")>0 then
response.Redirect("reg.asp?msg="&msg)
end if
if ac="adduser" then
set rsc=server.createobject("adodb.recordset")
sql="select * from info where username='"&request.Form("username")&"'"
rsc.open sql,conn,1,1
ck=rsc("username")
set rsc=nothing
if ck<>"" then
msg=msg&"<br>"&"用户名被人注册"
response.Redirect("reg.asp?msg="&msg)
end if
dsql="select * from info where id is null"
set rs=server.createobject("adodb.recordset")
rs.open dsql,conn,1,3
rs.addnew
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("mail")=request.Form("mail")
rs("sex")=request.Form("sex")
rs("qq")=request.Form("qq")
rs("add")=request.Form("add")
rs("personalinfo")=request.Form("personalinfo")
rs("ntime")=now
rs.update
set rs=nothing
%>
<center>
<a href="index.asp" target="_self">注册成功,点击登陆</a>
</center>
<%
end if
%>
</body>
</html>
6,(conn.asp 数据库连接文件)
<%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("userinfo.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0data source="
'创建记录对象
set rs=server.createobject("adodb.recordset")
%>
7,(userinfo.mdb ACCESS 数据库)
在ACCESS中建一个表,然后在这个表中建立字段名称
表名:info
字段名称 数据类型
id 自动编号
username 文本
password 文本
sex 文本
quest 文本
qq 文本
mail 文本
personalinfo 文本
ntime 文本
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)