我应该用ASP怎样写登录程序?

wds315 2002-04-25 12:58:29
http://www.brinkster.com/AspRules.asp


6. Do not put objects of any kind into Session or Application level variables.

我应该怎样写登录程序?
...全文
75 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
BrightEye 2002-04-26
  • 打赏
  • 举报
回复
连接数据库代码没有写出来.只要把这部分代码写出来,然后把表的名字改成自己需要的,基本上就可以直接用了。由于匆忙,漏了一点东西.:)<%
if Request.Form()="" then Response.write "拒绝访问!" :response.end
who=Trim(request.form("operator"))
passwd=Trim(request.form("passwd"))
if who="" then %>
<script>
<!--
alert("请输入工号!");
window.location.href=history.back(); //返回登陆页面.
-->
</script>
<%end if
if passwd="" then
%>
<script>
<!--
alert("请输入密码!");
window.location.href=history.back();
-->
</script>
<%end if
if who<>"" and passwd<>"" then
sql="select * from operator where operatorID='"&request.form("operator")&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
<!--
alert("工号输入错误!");
window.location.href=history.back();
-->
</script>
<%elseif passwd=rs("passwd") then
session("operatorID")=who '保存用户身份信息,以便下页使用,根据需要可以要,也可以不要
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "default.asp" '通过验证,定向到你要的页面
else
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script>
<!--
alert("密码错误,你无权登录!");
window.location.href=history.back();
-->
</script>
<%end if
end if
%>

l_xiaofeng 2002-04-26
  • 打赏
  • 举报
回复
能不能对程序做个解释,我也需要,但是我不会ASP,所以不知道如何改动/
谢谢各位!
ChinaOk 2002-04-26
  • 打赏
  • 举报
回复
怎么个不行法?
olay 2002-04-25
  • 打赏
  • 举报
回复
window.location是什么?
Iamfish 2002-04-25
  • 打赏
  • 举报
回复
谢谢各位,我花了一个下午的时间,把Sesseion改为Cookies了。在机子上可以运行,不过,不知在服务器上可不可以。
BrightEye 2002-04-25
  • 打赏
  • 举报
回复
这还不简单,很好写呀!:)给你一个参考.
<%
if Request.Form()="" then Response.write "拒绝访问!" :response.end
who=Trim(request.form("operator"))
passwd=Trim(request.form("passwd"))
if who="" then
'Response.Redirect "error.asp?id=210"%>
<script>
<!--
alert("请输入工号!");
window.location.href=history.back();
-->
</script>
<%end if
if passwd="" then
'Response.Redirect "error.asp?id=128"%>
<script>
<!--
alert("请输入密码!");
window.location.href=history.back();
-->
</script>
<%end if
if who<>"" and passwd<>"" then
sql="select * from operator where operatorID='"&request.form("operator")&"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.close
set rs=nothing
conn.close
set conn=nothing
'response.redirect "error.asp?id=253"%>
<script>
<!--
alert("工号输入错误!");
window.location.href=history.back();
-->
</script>
<%elseif passwd=rs("passwd") then
session("operatorID")=who
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "default.asp"
else
'response.redirect "error.asp?id=253"%>
<script>
<!--
alert("密码错误,你无权登录!");
window.location.href=history.back();
-->
</script>
<%end if
end if
%>
wangfei2428 2002-04-25
  • 打赏
  • 举报
回复
cookies依赖浏览器的设置,而且不安全。考虑把数据存放在数据库里
ChinaOk 2002-04-25
  • 打赏
  • 举报
回复
用cookies就可以了。
cookies不依靠session和application。
另外可以考虑在数据库里保存在线名单。

28,408

社区成员

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

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