<thead id="jxdzp"><address id="jxdzp"><pre id="jxdzp"></pre></address></thead>

<em id="jxdzp"><span id="jxdzp"></span></em>

    <listing id="jxdzp"><nobr id="jxdzp"><meter id="jxdzp"></meter></nobr></listing>

      <address id="jxdzp"></address>
      <noframes id="jxdzp"><form id="jxdzp"><th id="jxdzp"></th></form>
      <noframes id="jxdzp"><form id="jxdzp"><th id="jxdzp"></th></form>

          訂閱本欄目 RSS您所在的位置: 深山工作室 > ASP > 正文

          asp防止多個后臺用戶同時登陸

          深山工作室 2014/5/20 14:31:43 深山 字體: 瀏覽 4273
           表usr,用來存放注冊用戶的資料
          字段id '用戶ID
          字段name '用戶名
          字段pass '密碼
           
          表online,用來記錄用戶在線登陸情況,為了簡單我只建立三個字段
          字段oid '自動編號
          字段oname '用戶名
          字段odata '記錄活動時間(一開始是登陸時間)
           
          現在我們建立登陸頁login.asp
          <%
          if request("aciton")="chklog" then
          dim rs,name,pass
          name=trim(request.form("name"))
          pass=trim(request.form("pass"))
          if name="" or pass="" then
          response.write("<script>alert('用戶名,密碼都不能為空!');history.go(-1)</script>"
          response.end
          else
          '先查詢用戶名是否為注冊用戶
          set rs=conn.execute("select * from usr where name='"&name&"'")
          if rs.eof and rs.bof then '如果為空則提示錯誤
          rs.close:set rs=nothing '隨手關閉對象,釋放資源是個好習慣
          response.write("<script>alert('沒有該注冊用戶!');history.go(-1)</script>"
          response.end
          else
          if pass<>rs("pass") then '比較密碼
          rs.close:set rs=nothing
          response.write("<script>alert('密碼錯誤!');history.go(-1)</script>"
          response.end
          else
          rs.close:set rs=nothing 
          '用戶名,密碼都沒錯后,查詢該用戶名是否已存在于online表中
          set rs=conn.execute("select * from online where oname='"&name&"'")
          if rs.eof and rs.bof then '如果為空,則說明該用戶沒有登陸,插入該用戶名和當前時間
          rs.close:set rs=nothing
          conn.execute"insert into online(oname,odata) values ('"&name&"',now())
          session("username")=name
          session("userpass")=pass
          else '不為空說明該用戶已登陸,給出提示
          rs.close.set rs=nothing
          response.write("<script>alert('該用戶已登陸,如果你非正常退出,請5分鐘后再嘗試登陸!');history.go(-1)</script>"
          response.end
          end if
          end if
          end if
          response.redirect("index.asp") '轉到首頁
          end if
          end if
          %>
          下面html登陸代碼略過*******************************************************
           


           
          接著我們來寫退出頁面logout.asp
          <% if session("username")<>"" and session("userpass")<>"" then '不為空,先刪除online表中的記錄
          conn.execute"delete from online where oname='"&session("username")&"'"
          end if
          session("username")=""
          session("userpass")=""
          response.redirect("index.asp") 
          %>
           
           
           
          下面開始寫最重要的文件了 online.asp
           
          <%
          dim rs,name
          name=session("username")
          if name<>"" then '不為空時,則查詢online表是否存在該用戶名
          set rs=conn.execute("select * from online where oname='"&name&"'")
          if rs.eof and rs.bof then '為空時插入該用戶名記錄 
          rs.close:set rs=nothing
          conn.execute"insert into online(oname,odata) values ('"&name&"',now())"
          else '不為空時,則更新該用戶活動時間
          rs.close:set rs=nothing
          conn.execute"update online set odata=now() where oname='"&name&"'"
          end if
          end if
           conn.execute"delete from online where datediff('s',odata,now())>300" '刪除300秒內不活動的用戶!
          %>  
           
          相關閱讀
          深山留言板系統(七夕情人節專用) v3.7
          shopify廣告與Facebook廣告操作
          Instagram 廣告投放操作與技巧
          對MD5加密方式使用者的建議
          純div+css制作的彈出菜單-02
          我們使用的42個著名搜索引擎
          Request.ServerVariables在網頁中的一些應用集合
          asp頁面ip防火墻限制(判斷ip內網還是外網)功能
          共有0條關于《asp防止多個后臺用戶同時登陸》的評論
          發表評論
          正在加載評論......
          返回頂部發表評論
          呢 稱:
          表 情:
          內 容:
          評論內容:不能超過 1000 字,需審核,請自覺遵守互聯網相關政策法規。
          驗證碼: 驗證碼 
          網友評論聲明,請自覺遵守互聯網相關政策法規。

          您發布的評論即表示同意遵守以下條款:
          一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會、集體和公民的合法權益;
          二、不得發布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
          三、本站對您所發布內容擁有處置權。

          更多信息>>欄目類別選擇
          百度小程序開發
          微信小程序開發
          微信公眾號開發
          uni-app
          asp函數庫
          ASP
          DIV+CSS
          HTML
          python
          更多>>同類信息
          ASP中Utf-8與Gb2312編碼轉換亂碼問題的解決方法頁面編碼聲明
          asp顯示隨機密碼
          通過阿里云服務接口獲得ip地址詳細信息
          iis點開后任務欄上有顯示,但是窗口看不到的解決辦法
          RSA加密解密插件
          微軟Encoder加密解密函數
          更多>>最新添加文章
          dw里面查找替換使用正則刪除sqlserver里面的CONSTRAINT
          Android移動端自動化測試:使用UIAutomatorViewer與Selenium定位元素
          抖音直播音掛載小雪花 懂車帝小程序
          javascript獲取瀏覽器指紋可以用來做投票
          火狐Mozilla Firefox出現:無法載入您的Firefox配置文件 它可能已經丟失 或是無法訪問 問題解決集合處理辦法
          在Android、iOS、Windows、MacOS中微信小程序的文件存放路徑
          python通過代碼修改pip下載源讓下載庫飛起
          python里面requests.post返回的res.text還有其它的嗎
          更多>>隨機抽取信息
          一個利用radio單選選擇框進行變色的網頁效果
          微信小程序-接入廣告
          純asp根據當前日期計算出當前年份的屬相
          后臺編輯源碼里有行號
          window.location.href和setTimeout結合時間錯誤
          一個效果非常不錯圖片載入loading等待效果
          88国产精品视频一区二区三区