熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp完整登陸代碼

2022-06-13   來源: .NET編程 

  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="">&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/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>&nbsp;</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

  %>


From:http://tw.wingwit.com/Article/program/net/201311/14357.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.