<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      用ASP為你的網站加密

      [摘要]正在學習建設web站點的讀者,可能正在為站點的安全性而擔憂;也許你正在建設一個非公開性網站,只有系統用戶才可以訪問你的站點。如果你編制的是ASP網頁,那么你可以通過本文輕松達到這一目的。首先,你需要制作登錄頁面,在html中加入form,并設為自發送頁〈form name=″login″ acti...

      正在學習建設web站點的讀者,可能正在為站點的安全性而擔憂;也許你正在建設一個非公開性網站,只有系統用戶才可以訪問你的站點。如果你編制的是ASP網頁,那么你可以通過本文輕松達到這一目的。

      首先,你需要制作登錄頁面,在html中加入form,并設為自發送頁

      〈form name=″login″ action=″default.ASP″ method=″post″ target=″—top″〉

      action后接本頁url,這樣即使用戶登錄錯誤,在本頁即獲提示,而無須再返回前一頁登錄。在表單中加入

      〈input name=″uid″ size=″10″maxlength=″10″ style=″height: 21px; width: 101px″〉

      〈input name=″pwd″ type=″password″ size=″10″ maxlength=″10″〉  


      完成html后,在頁首填加程序代碼如下:

      〈% ′send customer direct to main page if already logged in

      if not isempty(session(″cust—id″)) and len(session(″cust—id″))〉0 then response.redirect(″navigation/dashbrd.ASP″)

      ′在此添入你真正的主頁url

      end if

      ′set flags

      blogin = false

      berror = false

      ′check blank entries

      if isempty(request(″uid″)) or len(request(″uid″)) = 0 or isempty(request(″pwd″)) or len(request(″pwd″)) = 0 then

      ′need to log in

      blogin = true

      else

      ′check user credentials against db

      … ′檢驗你的數據庫保存密碼表中是否有該用戶

      ′此處放入連接數據庫代碼

      ′其sql如下 ″select * from customer where cust—id=′″ & request(″uid″) & ″′ and ′cust—pwd=′″ & request(″pwd″) & ″′″

      ′其中request(″uid″)和request(″pwd″) 為本頁html中表單中的用戶名和密碼的text

      gbfound = false

      if not rscust.bof and not rscust.eof then

      gbfound = true

      end if

      if gbfound then

      ′record useful customer info in session variables

      session(″cust—id″) = rscust.fields(″cust—id″)

      ′ 此項為數據庫中用戶名

      session(″cust—pwd″) = rscust.fields(″cust—pwd″) ′此項為數據庫中用戶密碼

      session(″power″) = rscust.fields(″power″) ′此項為數據庫中用戶權限[可選]

      ′update last login time [可選]

      ′ rscust.activeconnection.execute (″update customer set cust—login = ′″& now & ″′ where cust_id = ″ & session(″cust—id″) & ″″)

      response.redirect(″navigation/dashbrd.ASP″) ′真正主頁url

      else

      ′uid and password not found

      berror = true blogin = true

      end if

      rscust.close

      ′close recordset

      mycn—login.close

      set mycn—login=nothing

      ′get all policy numbers held by customer

      end if

      %〉

      最后,你要做的就是在你的每一個頁面的開頭,加入以下代碼:

      〈% if isempty(session(″cust—id″)) or len(trim(session(″cust—id″)) = 0 then %〉

      〈script language=″javascript″ runat=client〉

      〈!——

      top.location.href = ″../default.ASP″

      //——〉

      〈script〉

      〈% response.end

      end if %〉  


      其中,session(″cust—id″) 為注冊的用戶名。

      top.location.href = ″../default.ASP″ 將自動導航到你的登錄界面。

      在這樣處理之后,恭喜你,你的web站點就有了安全登錄的功能。即使別人知道了你的站點的地址,在不進行合法登錄的情況下,也無法訪問其他網頁。并且,在你的網頁超時后,需要用戶重新登錄,這樣即便操作者臨時離開,也不必擔心非法者的惡意操作。


      日韩精品一区二区三区高清