下面是一个登陆页面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"> <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>密码用户不对!!! </font>" CASE 2 Response.write "<font color=red>你不是管理员吖! </font>" CASE 3 Response.write "<font color=red>你没进入权!! </font>" CASE 4 Response.write "<font color=red>管理帐号被锁定! </font>" CASE 7 Response.write "<font color=red>用户名含非法字符!!! </font>" CASE 8 Response.write "<font color=red>用户密码含非法字符! </font>" CASE 9 Response.write "<font color=red>校验码不正确! </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> <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" > <input type="reset" name="Guest" value="重 填" class="btx" onClick="location.href='index.asp';"> </td><td> <input type=hidden name='RememberUrl' value="<%=RememberUrl%>"> </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 %>>不保存 <br> </TD><TD></TD> </TR> </TR> </form> </TABLE></td> </TR> </TABLE> </td></TR></table> </td></TR></table> <br><br> <% End SUB