求:用户登陆(cookies)源代码

daynight2 2003-11-05 10:00:57
那位高手 有这个代码 asp+access 的 让小弟学习一下!

ps:如果我想在处理用户登陆时弹出对话框显示数据库的关于此用户的一条数据怎样做?
...全文
143 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
minghui000 2004-01-23
  • 打赏
  • 举报
回复
UP
hot.hot 2004-01-16
  • 打赏
  • 举报
回复
用XMLHTTP吧,在当前页不用提交就可以得到服务器上数据库的资料
nik_Amis 2004-01-16
  • 打赏
  • 举报
回复
up
hjt5 2004-01-16
  • 打赏
  • 举报
回复
讀cookies用

aa=request.cookies("aa") '把cookies的值賦給一個變量

response.cookies("aa")=aa '把變量的值寫到cookies裡面

如果你要用戶關閉瀏覽器就清除cookies,還不如用session方便

如果你非要這樣做,那去精華區看看好了
x_gn 2004-01-16
  • 打赏
  • 举报
回复
不要意思,发错了
就象happya3000的一样
happya3000 2004-01-16
  • 打赏
  • 举报
回复
读cookie就一句话

response.cookies("name")= "张三" // 写 cookie 值

name=request.cookies("name") // 读 cookie 值
response.write name

输出为“张三”
x_gn 2004-01-16
  • 打赏
  • 举报
回复
简单一点:
if response.cookie=rs("aa") then
response.write "登陆成功"
else
response.write "登陆失败"
end if
daynight2 2004-01-16
  • 打赏
  • 举报
回复
登陆后 怎么验证是否登陆 有无一段读cookies的代码?谢谢!

怎样在用户直接关闭浏览器的情况下清除cookies?是否是在离开时弹出窗口处理 ?怎样判断是否是离开整个站点了呢?
skylineforever 2003-12-23
  • 打赏
  • 举报
回复
靠,明明是cookie搞个session骗分啊
海鸥 2003-11-05
  • 打赏
  • 举报
回复
<% option explicit %>
<!--#include file="function/DBOpen.asp"-->
<%
if request("username")<>"" and request("userpassword")<>"" then
dim name
dim pwd
dim sql
dim rs,rs2
dim groupid
name=replace(request.form("username"),"'","''")
pwd=replace(request.form("userpassword"),"'","''")
set rs = server.createobject("adodb.recordset")
sql="select * from users where userid='" & name & "' and pwd='" & pwd & "' and flag=1"
rs.open sql,conn,1,1
if err.number <> 0 then
response.write "数据库操作失败:"&err.description
response.end
else
if not rs.eof and not rs.bof then
session("purview")=rs("purview")
session("name")=rs("userid")
groupid=rs("groupid")
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from [right] where groupid="&groupid&"",conn,1,1
if rs2.eof and session("purview")<>"99999" then
response.Write("<script>alert('您的权限不足以登陆本系统');</script>")
response.write("<script>history.back();</script>")
response.end
else
response.redirect "admin/index.asp"
end if
end if
end if
rs.close
set rs=nothing
end if
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>用户登陆</title>
<style>
<!--
p, td, body { font-size: 9pt; font-family: 宋体 }
input ,select { font-size: 9pt; font-family: 宋体}
a:link { color:#000000; text-decoration: none;}
a:visited { color:#000000; text-decoration: none;}
A:hover {color: #ff0000; text-decoration: underline;}
#kk{font-family:"宋体";font-size:9ptpx;color:#2b2b2b}
-->

</style>
</head>

<body bgcolor="#808080" topmargin="30">

<div align="center">
<center>
<form action="login.asp" method=post>   <br><br><br>
<table border="3" cellpadding="0" cellspacing="0" width="531" height="245" bgcolor="#FFFFFF" bordercolordark="#353535" bordercolor="#D7D7D7">
<tr>
<td width="531" height="245" bordercolor="#FFFFFF" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="60">
<tr>
<td width="100%" bgcolor="#D8F0D0" height="1"> </td>
</tr>
<tr>
<td width="100%" bgcolor="#D8F0D0" height="41" valign="top"> </td>
</tr>
<tr>
<td width="100%" bgcolor="#D8F0D0" height="14" valign="top"> </td>
</tr>
<tr>
<td width="100%" height="135" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="1">
<tr>
<td width="10%" height="1" rowspan="6"></td>
<td width="78%" height="9" valign="top" colspan="2">
</td>
<td width="12%" height="1" rowspan="6"></td>
</tr>

<tr>
<td width="78%" height="21" valign="top" colspan="2">
<p align="center"><font face="楷体_GB2312" size="4" color="#FF8400">用户登陆
</font>
</td>
</tr>
<tr>
<td width="78%" height="5" valign="top" colspan="2"> 

</td>
</tr>
<tr>
<td width="29%" height="1" valign="top">
<p align="right">用户名:
</td>

<td width="49%" height="1" valign="top">
<input type="text" name="username" class="input" size="18" maxlength="16" onMouseOver=this.focus()>
</td>
</tr>

<tr>
<td width="29%" height="26" valign="top">
<p align="right">口  令:
</td>

<td width="49%" height="26" valign="top">
<input type="password" name="userpassword" class="input" size="18" maxlength="14" onMouseOver=this.focus()>
</td>
</tr>
<tr>
<td width="78%" height="1" valign="top" colspan="2">
<p align="center"><input type="submit" value="登 录" class="button">
<input type="reset" value="重 置" name="B2">
</td>
</tr>
<tr>
<td width="10%" height="1"></td>
<td width="90%" height="1" colspan="2">
</td>
</tr>
<tr>
<td width="100%" height="8" colspan="4">
<hr color="#000000" size="1">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" height="36">
<p align="center"> </p>
</td>
</tr>
</table>
</td>
</tr>
</table> </form>
</div>

</body>

</html>
<!--#include file="function/DBClose.asp"-->
lovehwq21 2003-11-05
  • 打赏
  • 举报
回复
起个global.asa文件

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart

'--Project Data Connection
Application("ora8_ConnectionString") = "Driver={Microsoft Access driver(*.mdb)};Dbq=" & Server.MapPath("test.mdb")
Application("ora8_ConnectionTimeout") = 15
Application("ora8_CommandTimeout") = 30
Application("ora8_CursorLocation") = 3

set Application("ora8_Conn")=Server.CreateObject("ADODB.Connection")
Application("ora8_Conn").Open Application("ora8_ConnectionString")

End Sub

Sub Application_OnEnd

Application("ora8_Conn").Close()
set Application("ora8_Conn")=Nothing

End Sub

</SCRIPT>

用户登录check.asp

<%
set myResult = Server.CreateObject("Adodb.Recordset")
sSQL="select * from T_USER_INFO where USER_ID='" & trim(request("userid")) & "' and USER_PWD='" & trim(request("userpass")) &"'"
myResult.Open sSQL,Application("ora8_Conn"),3,3


if (myResult.bof and myResult.eof) then
myResult.close
response.redirect "index.asp"
response.end
else
session("user_id") = trim(myResult("USER_ID"))
session("user_name") = trim(myResult("USER_NAME"))
session("DEP_ID") = trim(myResult("DEP_ID"))
response.redirect "mainform.asp"
end if
myResult.close
%>
leiaming 2003-11-05
  • 打赏
  • 举报
回复
onclick="alert('<%=rs("记录")%>');"

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧