| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 763 人关注过本帖
标题:[求助]Cookie的问题,我太笨了。。。
取消只看楼主 加入收藏
青风
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2004-11-4
收藏
 问题点数:0 回复次数:1 
[求助]Cookie的问题,我太笨了。。。

下面是一个登陆页面LOGIN.ASP文件

我想把数据库中的 dj 字段加入Cookie中,插入下面的文件中,请高手帮忙,另外最好如何读取教我一下,呵呵,别笑我笨啊,谢谢

<!--#include FILE="CONST.ASP"--> <!-- #include file="inc/md5Fix.asp" --> <% 'if chkpost()=false then ' call response.write("<br><li>不允许外部提交发言!") ' response.end 'end if%> <!--#include FILE="inc/Syschar.asp"--> <!--#include FILE="inc/htmlhead.asp"--> <% Response.Expires = 0 Response.AddHeader "Pragma", "no-cache" Response.AddHeader "cache-control", "no-store"

dim membername dim memberid dim MasterFlag dim ErrorNumber

ErrorNumber=0 MasterFlag=0 if GetAction="exit" then Session("userpath")="" Session("UserName")="" Session("coo_port")="" Session("Master.ASP")="" Response.cookies("CooSel")("UserName")="" Response.cookies("CooSel")("password")="" Response.cookies("CooSel")("UserID")="" Response.cookies("CooSel")("MasterFlag")="" 'response.write "已经退出CooSel管理!,如需再登陆,请选择初始入口" 'response.end end if membername=checkStr(request.cookies("CooSel")("UserName")) memberid=GetValue(request.cookies("CooSel")("userid"),"int",-1) MasterFlag=checkStr(request.cookies("CooSel")("MasterFlag")) if MasterFlag="" then MasterFlag=0 else MasterFlag=clng(MasterFlag) end if

dim RememberUrl if Request.form("RememberUrl")="" then RememberUrl=HTTP_REFERER else RememberUrl=Request.form("RememberUrl") end if DIM usercookies DIM loginTO usercookies=GetValue(request.form("SaveLoginCookie"),"int",0) loginTO=GetValue(request.queryString("loginTO"),"int",0) if loginTO=0 then loginTO=GetValue(request.form("loginTO"),"int",0) %>

<head> <style type="text/css"> <!-- A:LINK {Text-Decoration: none; color:#775500;} A:VISITED {Text-Decoration: none; color:#775500;} A:Active {Text-Decoration: none; color:#775500;} A:HOVER {Text-Decoration: underline; color:#ffff55;} --> .textField { FONT-SIZE: 9pt; COLOR: #000000; FONT-FAMILY: 宋体,MS SONG,SimSun,Arial, Helvetica, sans-serif; BACKGROUND-COLOR: #ffffff </style> <SCRIPT LANGUAGE="JavaScript"> <!-- function noInput() { if ((form1.FormUserName.value=="")||(form1.FormUserPassword.value=="")||(form1.GetCode.value=="")) {return (!!(window.alert('输入不能有空')));} else{return true;} } //使用onKeydown='onlyNum();'屏蔽掉非数字输入 function onlyNum() { var keys=event.keyCode if (!((keys>=48&&keys<=57)||(keys>=96&&keys<=105) ||(keys==8)||(keys==46)||(keys==37)||(keys==39)||(keys==13)||(keys==229) )) event.returnValue=false;} //--> </SCRIPT> <title></title> </head> <body bgcolor="#f3f3f3" text="#000000" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="20" background="pic/back.gif"> <% GetPath=session("UserPath") if GetPath="" then set rs=Server.CreateObject("ADODB.RecordSet") rs.open "select UserPath from [UserList] where UserID="&memberid,CONN,0,1 if Not rs.eof then GetPath=rs(0) end if rs.close set rs=nothing end if %> <!--#include file="TopNav.asp" --><br><br> <% if GetAction="login" then ErrorNumber=LoginCheck() '同时使用函数返回值

if membername<>"" then Select CASE loginTO CASE 1 Response.Redirect("This_upfile_adv.asp") CASE 2 Response.Redirect("Files_brower.asp") CASE 3 Response.Redirect("EditBrower.asp") CASE 4 Response.Redirect("ADO_recordset.asp") CASE 5 Response.Redirect("reg_info.asp") CASE else call loginOk() End Select else call LoginMain() end if

%>

<% '-------登陆检测 Function LoginCheck() dim rs,sql dim Master dim PassWord dim memberid dim GetUserName dim GetUserPassWord dim userip dim Getlogin Getlogin=GetValue(request.form("SubmitLogin"),"str","") GetUserName=CheckStr(GetValue(request.form("FormUserName"),"str","")) GetUserPassWord=GetValue(request.form("FormUserPassword"),"str","") if Request.ServerVariables("HTTP_X_FORWARDED_FOR")="" then userip=checkStr(request.servervariables("remote_addr")) else userip=checkStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR")) end if dim GetCode GetCode=GetValue(request.form("GetCode"),"int",-1) if GetCode<>int(Session("GetCode")) then LoginCheck=9 exit Function end iF IF GetUserName<>"" and GetUserPassWord<>"" then if instr(GetUserName,"'")>0 or instr(GetUserName,";")>0 then LoginCheck=7 exit Function end if if instr(GetUserPassWord,"'")>0 or instr(GetUserPassWord,";")>0 then LoginCheck=8 exit Function end if 'sql="select * from [userlist] where UserName='"&GetUserName&"' and UserPassword='"&md5(GetUserPassWord,md5order)&"'" sql="select * from [userlist] where UserName='"&GetUserName&"' and UserPassword='"&md5(GetUserPassWord,md5order)&"'" set rs=CONN.Execute(sql) if rs.EOF then LoginCheck=1 exit Function else if rs("Active")=0 then Call GetError("<br><li>该帐号尚未被激活,不能完成登陆!") end if Session("userpath") =rs("UserPath") Session("UserName")=rs("UserName") GetPath=rs("UserPath") dim initPath initPath=rs("UserPath") select case usercookies case 1 Response.cookies("CooSel").Expires=DateAdd("d",9999,now()) end select Response.cookies("CooSel")("UserName") = rs("UserName") Response.cookies("CooSel")("password") = rs("Userpassword") Response.cookies("CooSel")("UserID") = rs("UserID") Response.cookies("CooSel")("MasterFlag") = rs("MasterFlag") MasterFlag=rs("MasterFlag") end if rs.CLOSE iF LoginCheck=0 then if Getlogin="登 陆" then dim GetMySize:GetMySize=0 dim tmpArr,ubt,i tmpArr=split(initPath,"|") ubt=ubound(tmpArr) GetMySize=GetFsoSize(tmpArr(0)) if ubt>0 then for i=1 to ubt GetMySize=GetMySize&"|"&GetFsoSize(tmpArr(i)) next end if 'GetMySize=GetFsoSize(initPath) CONN.Execute("update [userlist] set LastloginIp='"&userip&"',useSize='"&GetMySize&"' where UserName='"&GetUserName&"'") Response.Redirect("login.asp?action=true&LoginTO="&loginTO) end if eND if set rs=nothing END if END Function

'--------登陆界面涵数 SUB LoginMain() Session("UserName")="" Session("userpath")="" Session("Master.ASP")="" if GetAction="exit" then Response.cookies("CooSel")("UserName")="" Response.cookies("CooSel")("password")="" Response.cookies("CooSel")("UserID")="" end if dim reg,sql,rs %>

<table width="550" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333369" ><tr><td> <table width="100%" height="100%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#ffffff" ><tr><td>

<TABLE WIDTH="100%" BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 background="pic/back.gif"> <tr> <td height="24" background="pic/title.gif"> <p align="center">&nbsp;&nbsp;<strong><font color="#FFFFFF">方舟网免费空间登陆</font></strong></p> </td> </TR> <tr> <td valign=top> <TABLE BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0> <form name="form1" method="post" action="login.asp?action=login" onSubmit="return noInput();"> <TR> <TD height="30" align="center" valign="bottom" > </TD> <TR> <TD align="right" valign="bottom" > <% select CASE ErrorNumber CASE 1 Response.write "<font color=red>密码用户不对!!!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 2 Response.write "<font color=red>你不是管理员吖!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 3 Response.write "<font color=red>你没进入权!!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 4 Response.write "<font color=red>管理帐号被锁定!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 7 Response.write "<font color=red>用户名含非法字符!!!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 8 Response.write "<font color=red>用户密码含非法字符!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" CASE 9 Response.write "<font color=red>校验码不正确!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>" end select %> </td></TR><tr><td> <b>用 户: </b><input type="text" class="textField" name="FormUserName" style="width:176;"> </td></TR><tr><td> <b>密 码: </b><input type="password" class="textField" name="FormUserPassword" style="width:176;"> </td></TR> <TR> <TD align="right" valign="top" > <b>验证码: </b><input type="text" class="textField" name="GetCode" onKeyDown="onlyNum();" style="width:176;"></td> <td>&nbsp;<span style="background-color:#ffffff"><img src="inc/iGetCodeJS.asp?<%=timer()%>"></span></td> </TR> <TR> <TD align="right" valign="top"> <b>登陆到: <SELECT NAME="loginTO" style="width:176;"> <option value="0" <%if loginTO=0 then%>selected<%end if%>>不 选 择</option> <option value="1" <%if loginTO=1 then%>selected<%end if%>>文件上传</option> <option value="2" <%if loginTO=2 then%>selected<%end if%>>文件管理</option> <option value="3" <%if loginTO=3 then%>selected<%end if%>>文件编辑</option> <option value="4" <%if loginTO=4 then%>selected<%end if%>>数 据 库</option> <option value="5" <%if loginTO=5 then%>selected<%end if%>>本人档案</option> </SELECT></b></td><td></td> </TR>

<TR> <TD align="right" height=50> <input type="submit" name="SubmitLogin" value="登 陆" class="btx" >   &nbsp;&nbsp; <input type="reset" name="Guest" value="重 填" class="btx" onClick="location.href='index.asp';">&nbsp;&nbsp; </td><td> <input type=hidden name='RememberUrl' value="<%=RememberUrl%>">&nbsp;&nbsp; </TD> </TR> <TR> <TD align="right" valign="middle" > 自动登陆: <input TYPE="radio" name="SaveLoginCookie" value=1 <%if usercookies=1 then response.write "checked" end if %>>保存 <input TYPE="radio" name="SaveLoginCookie" value=0 <%if usercookies=0 then response.write "checked" end if %>>不保存 &nbsp;<br> </TD><TD></TD> </TR> </TR> </form> </TABLE></td> </TR> </TABLE> </td></TR></table> </td></TR></table> <br><br> <% End SUB

搜索更多相关主题的帖子: Cookie 
2004-11-09 19:55
青风
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2004-11-4
收藏
得分:0 

代码太长了,一次没粘完,我也不知道该粘哪段,所以全粘上了,下面还有

SUB loginOk() dim rs,GroupID,uSizeArr,upath,quotaArr dim infos dim txt1,txt2,txt3 infos=request.querystring("infos") if infos="" then txt1="【登 陆 完 成】" txt2="<br>登陆成功,请选择管理项目!&nbsp;&nbsp;<br><br>" txt3="<input type=""button"" name=""denglu1"" value=""重登陆"" class=""btx"" onclick=""location.href='login.asp?action=exit';"">&nbsp;&nbsp;&nbsp;&nbsp;" if SetPower(2,6)=true then txt3=txt3&"<input type=""Submit"" name=""denglu1"" value=""管 理"" class=""btx"" >&nbsp;&nbsp;&nbsp;&nbsp;" end if txt3=txt3&"<input type=hidden name='RememberUrl' value="""&Request.ServerVariables("HTTP_REFERER")&""">" else txt1="【空 间 信 息】" txt2="<img src=pic/coosel.gif border=0>" txt3="" end if sql="select * from [userlist] where UserID="&GetValue(request.cookies("CooSel")("userid"),"int",-1)&" and UserPassword='"&checkStr(request.cookies("CooSel")("password"))&"'" set rs=Server.CreateObject("ADODB.RecordSet") rs.open sql,conn,0,1 if not rs.eof then GroupID=rs("GroupID") MasterFlag=rs("MasterFlag") pow=rs("sFlag") uSizeArr=split(rs("useSize"),"|") upath=split(rs("userpath"),"|") quotaArr=split(rs("useQuota"),"|") for i=0 to ubound(quotaArr) if quotaArr(i)<0 then quotaArr(i)="不限制" else if isnumeric(quotaArr(i)) then if quotaArr(i)="-1" then quotaArr(i)="不限制" else quotaArr(i)=quotaArr(i)&"MB" end if else quotaArr(i)="0MB" end if end if next for i=0 to ubound(uSizeArr) if isnumeric(uSizeArr(i)) then uSizeArr(i)=formatnumber((csng(uSizeArr(i))/1024)/1024,2,-1)&"MB" else uSizeArr(i)="0MB" end if next if GroupID>0 then rs.close rs.open "select GroupSet,GroupQuota from [Groups] where GroupID="&GroupID,conn,0,1 if not rs.eof then pow=rs(0) for i=0 to ubound(quotaArr) if rs("GroupQuota")=-1 then quotaArr(i)="不限制" else quotaArr(i)=rs("GroupQuota")&"MB" end if next else pow="" for i=0 to ubound(quotaArr) quotaArr(i)="" next end if end if if pow<>"" then pow=split(pow,",") select case MasterFlag case 0 for i=0 to ubound(pow) '普通用初始化权限 for j=1 to 9 if mid(pow(i),j,1)="1" then SetPower(i,j-1)=true next next case 1 for i=0 to ubound(pow) '普通管理员初始化权限 for j=1 to 9 if mid(pow(i),j,1)="1" then SetPower(i,j-1)=true next next case 2 for i=0 to 2 for j=0 to 8 SetPower(i,j)=true next next end select end if else uSizeArr=split("","|") upath=split("","|") quotaArr=split("","|") end if rs.close set rs=nothing %> <TABLE WIDTH='95%' BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0> <tr> <td valign="top" style='background-image: url(&#039;pic/DES1_06.gif&#039;); background-repeat: repeat-x; background-position: 0px 28px'>&nbsp;</td> <td WIDTH=795> <TABLE WIDTH=795 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 > <form name="form1" method="post" action="Master.asp"> <TR> <TD COLSPAN=4>&nbsp; </TD> <TD COLSPAN=2 background="pic/DES1_02.gif">&nbsp; </TD> <TD valign="bottom"><a href="http://www.99081.com">WWW.99081.COM</a></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=28 ALT="" ></TD> </TR> <TR> <TD HEIGHT=11 COLSPAN=4 background="pic/DES1_04.gif"></TD> <TD COLSPAN=2 background="pic/DES1_05.gif"></TD> <TD background="pic/DES1_06.gif"></TD> <TD background="pic/DES1_06.gif"><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=11 ALT=""></TD> </TR> <TR> <TD ROWSPAN=5>&nbsp; </TD> <TD COLSPAN=4 align="center" background="pic/DES1_08.gif"><font color=#008800><%=txt1%></font></TD> <TD ROWSPAN=3 background="pic/DES1_09.gif">&nbsp; </TD> <TD ROWSPAN=5>&nbsp; </TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=26 ALT=""></TD> </TR> <TR> <TD background="pic/DES1_11.gif">&nbsp; </TD> <TD align="right" valign="middle" background="pic/DES1_12.gif" bgcolor="#DDDBD7"> <%=txt2%> <%=txt3%> &nbsp;&nbsp;</TD> <TD COLSPAN=2 background="pic/DES1_13.gif"> <%if SetPower(2,4)=true then%><a href="Files_brower.asp" ><img src="pic/file.gif" onmouseover="this.src='pic/file_h.gif'" onmouseout="this.src='pic/file.gif'" width="91" height="20" border="0"></a><%else%><img src="pic/bob.gif" onmouseover="this.src='pic/bob_h.gif'" onmouseout="this.src='pic/bob.gif'" width="91" height="20" border="0"><%end if%><br><img height=4 width=0><br> <%if SetPower(2,3)=true then%><a href="This_upfile_adv.asp" ><img src="pic/upload.gif" onMouseOver="this.src='pic/upload_h.gif'" onMouseOut="this.src='pic/upload.gif'" width="90" height="19" border="0"></a><%else%><img src="pic/bob.gif" onmouseover="this.src='pic/bob_h.gif'" onmouseout="this.src='pic/bob.gif'" width="91" height="20" border="0"><%end if%><br><img height=4 width=0><br> <%if SetPower(2,4)=true then%> <%else%> <%end if%><img height=4 width=0><br> <%if SetPower(2,7)=true then%> <a href="EditBrower.asp"><img src="pic/edit.gif" onMouseOver="this.src='pic/edit_h.gif'" onMouseOut="this.src='pic/edit.gif'" width="90" height="19" border="0"></a><br><a href="ADO_recordset.asp"><img src="pic/data.gif" onMouseOver="this.src='pic/data_h.gif'" onMouseOut="this.src='pic/data.gif'" width="90" height="19" border="0"></a> <%else%> <img src="pic/bob.gif" onMouseOver="this.src='pic/bob_h.gif'" onMouseOut="this.src='pic/bob.gif'" width="91" height="20" border="0"><br><img src="pic/bob.gif" onmouseover="this.src='pic/bob_h.gif'" onmouseout="this.src='pic/bob.gif'" width="91" height="20" border="0"> <%end if%> </TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=115 ALT=""></TD> </TR> <TR> <TD COLSPAN=4 ROWSPAN=2 background="pic/DES1_14.gif">&nbsp; </TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD> </TR> <TR> <TD ROWSPAN=2></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=28 ALT=""></TD> </TR> <TR> <TD COLSPAN=4 align="left" valign="top" background="pic/DES1_16.gif"> <b>帐号信息</b><%if groupid>0 then%>(属于用户组)<%else%>(属于独立用户)<%end if%><br> <TABLE width="99%" border=0 cellpadding=2 cellspacing=1 rules=rows bordercolordark=#eeeeee bordercolorlight=#bbbbbb> <TR bgcolor=#cccccc> <TD >空间目录</TD> <TD>空间配额</TD> <TD>已用数额</TD> </TR> <% for i=0 to ubound(upath)%> <TR bgcolor=#cccccc> <TD><%=upath(i)%></TD> <TD><%=quotaArr(i)%></TD> <TD><%=uSizeArr(i)%></TD> </TR> <%next%> </TABLE> </TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=229 ALT=""></TD> </TR> <TR> <TD><IMG SRC="pic/spacer.gif" WIDTH=174 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=43 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=241 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=91 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=89 HEIGHT=1 ALT=""></TD> <TD><IMG SRC="pic/spacer.gif" WIDTH=156 HEIGHT=1 ALT=""></TD> </TR></form> </TABLE> </td> <td valign="top" style='background-image: url(&#039;pic/DES1_06.gif&#039;); background-repeat: repeat-x; background-position: 1px 28px'>&nbsp;</td> </TR> </TABLE> <%EnD SUB

'单引号转义 Function checkStr(str) if isnull(str) then checkStr = "" exit Function end if checkStr=replace(str,"'","") checkStr=replace(str,";","") End Function

'----- 判断发言是否来自外部 Function ChkPost() dim server_v1,server_v2 chkpost=false server_v1=Cstr(Request.ServerVariables("HTTP_REFERER")) server_v2=Cstr(Request.ServerVariables("SERVER_NAME")) '转移至checkuser.asp 'if session("coo_port")="" then ' GetError "错误的登陆入口,或你不具备进入CooSel的基本权限,请确认并选择正确的登陆入口" 'end if 'if inStr(1,server_v1,"") if mid(server_v1,8,len(server_v2))<>server_v2 then chkpost=false else chkpost=true end if End Function%>

2004-11-09 19:57
快速回复:[求助]Cookie的问题,我太笨了。。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026907 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved