asp完整登陆代码
<%
option explicit
强制浏览器重新访问服务器下载页面而不是从缓存读取页面
ResponseBuffer = True
ResponseExpires =
ResponseExpiresAbsolute = Now()
ResponseExpires =
ResponseCacheControl = "nocache"
主要是使随机出现的图片数字随机
%>
<!#include file="inc/configasp">
<!DOCTYPE HTML PUBLIC "//WC//DTD HTML Transitional//EN">
<HTML>
<HEAD>
<TITLE><%=rs_config("c_incname")%>管理员登录</TITLE>
<meta httpequiv="ContentType" content="text/html; charset=gb">
<LINK href="inc/logincss" rel=stylesheet type=text/css>
<base target="main">
<style type="text/css">
<!
style {fontsize: pt}
>
</style>
<SCRIPT language=JavaScript>
<!
function frmSubmit() {
if (theFormnamevalue == "") {
alert("请输入用户名");
theFormnamefocus();
return false;
}
if (theFormpassvalue == "") {
alert("请输入密码");
theFormpassfocus();
return false;
}
if (theFormsafecodevalue == "") {
alert("请输入校验码");
theFormsafecodefocus();
return false;
}
return true;
}
//>
</SCRIPT>
<link rel="icon" href="/faviconico" type="image/xicon" />
<link rel="shortcut icon" href="/faviconico" type="image/xicon" />
<META httpequiv=ContentType content="text/html; charset=gb">
<LINK
href="images/WEIcss" 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= style="bordercollapse: collapse" bordercolor="#">
<TBODY>
<TR>
<TD width="">
<TABLE align="center" cellSpacing= cellPadding= width= border= style="bordercollapse: collapse" bordercolor="#">
<TBODY>
<TR>
<TD vAlign=top width="" height="">
<FORM action=logincheckasp method=POST target="_top">
<table width="" border="" align="center" cellpadding="" cellspacing="">
<tr>
<td colspan=""><img src="images/Admin_Logingif" width="" height=""></td>
</tr>
<tr>
<td width="" valign="top" background="Images/Admin_Logingif"><table width="" border="" cellspacing="" cellpadding="">
<tr>
<td height="" colspan=""> </td>
</tr>
<tr>
<td width="" rowspan=""> </td>
<td width=""><font color="#BC">用户名称</font></td>
<td width="" rowspan=""> </td>
<td width=""><font color="#BC">用户密码</font></td>
<td width=""> </td>
<td width=""><font color="#BC">验证码<b><font color=#ff><IMG
src="inc/Codeasp" width="" height="" align="absmiddle"></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> </td>
<td><INPUT name="safecode" type=text id="safecode" size=></td>
</tr>
</table></td>
<td>
<input type="image" name="Submit" src="Images/Admin_Logingif" style="width:px; HEIGHT: px;"></td>
</tr>
</table>
</FORM>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
下面是asp处理文件
<%@LANGUAGE="VBSCRIPT" CODEPAGE=""%>
<meta httpequiv="ContentType" content="text/html; charset=gb">
<!#include file="connasp">
<!#include file="mdasp">
<%
function ChkPost()
dim server_vserver_v
chkpost=false
server_v=Cstr(RequestServerVariables("HTTP_REFERER"))
server_v=Cstr(RequestServerVariables("SERVER_NAME"))
if mid(server_vlen(server_v))<>server_v then
chkpost=false
else
chkpost=true
End if
End function
sessionTimeout=
if ChkPost=false then
emsg="请不要从其它站点提交表"
responseRedirect("loginasp?emsg=请不要从其它站点提交表")
ResponseEnd()
End if
dim anameapassFoundErrErrMsg
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)
Connclose
Set Conn=Nothing
else
apass=md(apass)
dim sqlrs
sql="select a_namea_passa_flag from admin where a_name="&aname&" and a_pass="&apass&""
set rs=servercreateobject("adodbrecordset")
rsopen sqlconn
if rsBOF and rsEOF then
ErrMsg="用户名或是密码错误!"
Call LoginError(ErrMsg)
rsclose
set rs=Nothing
connclose
set conn=Nothing
responseEnd
elseif Not(rsBOF or rsEOF) then
session("aname")=rs("a_name")
session("admin_flag")="into"
session("admin_sys")=rs("a_flag")
responseRedirect("useradminasp")
rsclose
set rs=Nothing
connclose
set conn=Nothing
responseEnd
End if
end if
Sub LoginError(EMsg)
responsewrite "<script language=javascript>" & chr()
responsewrite "alert("&EMsg&");" & Chr()
responsewrite "windowdocumentlocation;"&Chr()
responsewrite "</script>" & Chr()
ResponseEnd
End Sub
%>