萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> asp編程 >> asp完整登陸代碼

asp完整登陸代碼

asp完整登陸代碼
<%
option explicit
強制浏覽器重新訪問服務器下載頁面,而不是從緩存讀取頁面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
主要是使隨機出現的圖片數字隨機
%>
<!--#include file="inc/config.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE><%=rs_config("c_incname")%>-管理員登錄</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="inc/login.css" rel=stylesheet type=text/css>
<base target="main">
<style type="text/css">
<!--
.style2 {font-size: 12pt}
-->
</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 http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK
href="images/WEI.css" type=text/css rel=stylesheet>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<BR>
<br>
<br>
<br>
<br>
<BR>
<TABLE align="center" cellSpacing=0 cellPadding=0 width=555 border=0 style="border-collapse: collapse" bordercolor="#111111">
<TBODY>
<TR>
<TD width="588">
<TABLE align="center" cellSpacing=0 cellPadding=0 width=558 border=0 style="border-collapse: collapse" bordercolor="#111111">
<TBODY>
<TR>
<TD vAlign=top width="360" height="104">
<FORM action=logincheck.asp method=POST target="_top">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><img src="images/Admin_Login1.gif" width="600" height="126"></td>
  </tr>
  <tr>
    <td width="508" valign="top" background="Images/Admin_Login2.gif"><table width="508" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="37" colspan="6">&nbsp;</td>
        </tr>
        <tr>
          <td width="75" rowspan="2">&nbsp;</td>
          <td width="126"><font color="#043BC9">用戶名稱:</font></td>
          <td width="39" rowspan="2">&nbsp;</td>
          <td width="131"><font color="#043BC9">用戶密碼:</font></td>
          <td width="34">&nbsp;</td>
          <td width="103"><font color="#043BC9">驗證碼:<b><font color=#ff0000><IMG
                              src="inc/Code.asp" width="40" height="10" align="absmiddle"></font></b></font></td>
        </tr>
        <tr>
          <td><input name=name id="name" size=15></td>
          <td><input name=pass type=password id="pass" size=12></td>
          <td>&nbsp;</td>
          <td><INPUT name="safecode" type=text id="safecode" size=12></td>
          </tr>
    </table></td>
    <td>
      <input type="image" name="Submit" src="Images/Admin_Login3.gif" style="width:92px; HEIGHT: 126px;"></td>
  </tr>
</table>
</FORM>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

下面是asp處理文件
 <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->

<%
function ChkPost()
 dim server_v1,server_v2
 chkpost=false
 server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
 server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
 if mid(server_v1,8,len(server_v2))<>server_v2 then
  chkpost=false
 else
  chkpost=true
 End if
End function
session.Timeout=20
if ChkPost=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)>20 or len(aname)<3  then
   FoundErr=True
   ErrMsg=ErrMsg&"用戶名不對!nn"
End if

if len(apass)>20 or len(apass)<6  then
&nbs

copyright © 萬盛學電腦網 all rights reserved