2011 本站教學範例已全面更新~ 新教學請看 http://www.flycan.com/article/   【到新的教學討論區】
【飛肯設計學苑】- 回首頁 -
回首頁最新開課訊息企業包班教育訓練範例教學區問題討論區交流分享區程式下載區
Photoshop影像達人專修班 Photoshop 遮色片 & 色版創作進階班 CSS 版面設計專修班 ActionScript 3.0 程式設計入門班 ActionScript & XML 進階整合應用班 Dreamweaver & CSS網頁版型設計班

 

本站已全面更新~ 2011年 新教學範例請看 → http://www.flycan.com/article/

 

【DW PHP 資料庫】問題討論區
請教一個 Dreamweaver + ASP 的問題

發表新主題   回覆主題
【飛肯】教學網站 首頁 » 【DW PHP 資料庫】問題討論區
上一篇主題 :: 下一篇主題  
發表人 內容
ajam
【新生】
【新生】


註冊時間: 2006-02-21
文章: 3

發表請教一個 Dreamweaver + ASP 的問題 引言回覆

發表於: 2006-02-21 05:39 
請教各位大大,

使用Dreamweaver + ASP 有可能完成防止單一帳號重覆登入的情形嗎?

也就是說,我希望程式能達成單一帳號同一時間只能由單一台PC登入。

希望大大指點迷津,謝謝。

回頂端
檢視會員個人資料 發送私人訊息
steady
【二年級】
【二年級】


註冊時間: 2005-12-26
文章: 11

發表回覆問題 引言回覆

發表於: 2006-02-21 09:45 
在資料庫的欄位上作判斷例如

Table Users

ID|PASSWORD| STATUS

--------------------------------------

myid| mypass| 0

STATUS設為0代表未登入 設為1代表已登入

當登入時設為1

當登出或關閉瀏覽器時設為0

關閉瀏覽器可以如下判斷

<body onunload="goout()">

</body>

<Script Language="javascript">

function goout()

{

wid=window.open ("登出.asp","","width=500,height=500");

}

</Script>

回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
ajam
【新生】
【新生】


註冊時間: 2006-02-21
文章: 3

發表 引言回覆

發表於: 2006-02-23 07:45 
感謝steady大大指點,

我在努力試試看,

另外再請教一個問題喔,

當地一個使用者登入後,STATUS會被更新為1,

但是第二位使用者以相同密碼登入時,一樣能夠登入,

因為Dreamweaver的驗證僅有USERNAME和PASSWORD,

並沒辦法驗證STATUS狀態,

所以第二位登入者依然能夠存取網路資源,

我該如何將他[驅逐出境]呢?

很抱歉,小弟只是Dreamweaver的使用者,對ASP似懂非懂,

問題瑣碎還望大大海涵。再次感謝。

回頂端
檢視會員個人資料 發送私人訊息
steady
【二年級】
【二年級】


註冊時間: 2005-12-26
文章: 11

發表steady的回覆 引言回覆

發表於: 2006-02-28 10:13 
不會就要學,會asp連資料庫的薪水絕對比只會dreanwaver高,而且解決問題不能只局限於一種工具.以下是我的範例並沒有很完美,但是已有達到你的功能了.

http://140.122.118.40/test.asp

(範例只能周一到周五的早上9:00到18:00看的到,個人電腦的問題看之前要按重新整理)(資料庫保密不能公怖)

原始碼

-------------------------------------------------------------------------------------

test.asp

-------------------------------------------------------------------------------------

<form method="POST" action="test2.asp">

<center>

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="400">

<tr>

<td width="200" align="center">帳號</td>

<td width="200">

<p align="center"><INPUT type="text" id="eng" size="20" name="theid"></td>

</tr>

<tr>

<td width="200" align="center">密碼</td>

<td width="200">

<p align="center"><INPUT type="password" id="eng0" size="20" name="thepassword"></td>

</tr>

</table><INPUT type="submit" value="送出">

</center>

</form>

-------------------------------------------------------------------------------------

test2.asp

-------------------------------------------------------------------------------------

<Script Language="javascript">

function goout()

{

var wid=window.open ("test3.asp?theid=<%=request("theid")%>","","width=500,height=500");

}

</Script>

<body onunload="goout()">

<%

function Error(str)

response.write "<script>" & VbCrLf

response.write "alert('"&str&"')" & VbCrLf

response.write "history.go(-1)" & VbCrLf

response.write "</script>" & VbCrLf

response.end

end function

Set Conn=Server.CreateObject("ADODB.Connection")

Conn.Open "保密"

sqlstr="select * from theuser where theid='" & request("theid") & "' and thepassword= '" & request("thepassword") & "'"

Set rs=Server.CreateObject("ADODB.Recordset")

rs.Open sqlstr,Conn,adOpenKeyset,3,adCmdText

if rs.eof then error "帳號或密碼錯誤"

if rs("thestatus")=1 then error "已有人使用不得使用"

if rs("thestatus")=0 then

sqlstr="update theuser set thestatus=1 where theid='" & request("theid") & "'"

conn.execute(sqlstr)

%>

使用中

<input type="button" value="登出" name="B1" onclick="window.close()"></p>

<%

end if

%>

</body>

-------------------------------------------------------------------------------------

test3.asp

-------------------------------------------------------------------------------------

<%

function ShowMessage(str,url)

response.write "<script>" & VbCrLf

response.write "location.href='"&url&"'" & VbCrLf

response.write "alert('"&str&"')" & VbCrLf

response.write "</script>" & VbCrLf

response.end

end function

Set Conn=Server.CreateObject("ADODB.Connection")

Conn.Open "保密"

sqlstr="update theuser set thestatus=0 where theid='" & request("theid") & "'"

conn.execute(sqlstr)

ShowMessage "你已登出","test.asp"

%>

回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
steady
【二年級】
【二年級】


註冊時間: 2005-12-26
文章: 11

發表steady回覆 引言回覆

發表於: 2006-02-28 10:22 
帳號是id

密碼是password

回頂端
檢視會員個人資料 發送私人訊息 發送電子郵件
ajam
【新生】
【新生】


註冊時間: 2006-02-21
文章: 3

發表 引言回覆

發表於: 2006-03-03 05:03 
再次謝謝大大不厭其煩指導,

感恩喔,有到網站去試過了,謝謝你。

回頂端
檢視會員個人資料 發送私人訊息
從之前的文章開始顯示:   
發表新主題   回覆主題     1頁(共1頁)
【飛肯】教學網站 首頁 » 【DW PHP 資料庫】問題討論區

 
所有的時間均為 台北時間 (GMT + 8 小時)
前往:  

回首頁】【最新開課訊息】【企業委訓】【範例教學分享區】【問題討論區