ASP登入检测缺少对象,请高手指点~~~

来源:百度知道 编辑:UC知道 时间:2024/07/04 23:35:47
<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>检查登录</title>
</head>
<body topmargin=0>
<!--#include file="连接.asp"-->
<!--#include file=函数.asp-->
<%
session("logname")=request("username")
dim username,password
username=request("username")
password=request("password")

sql="select * from book.huiyuan where username='"&username&"' and password='"&password&"'"
rs.open sql,conn,3,2

if not rs.eof then

rs("isonline")=True
rs("logintime")=now()
rs("ip")=Request.ServerVariables("REMOTE_HOST")
rs.update

response.redirect "登入页面.asp"
else
session("storage")=0
ShowError("用户名或密码错误!")
end if
rs.close
%>

很明显!你没有创建记录集对象RS,何来下面的rs.open sql,conn,3,2?

应该改为:
sql="select * from book.huiyuan where username='"&username&"' and password='"&password&"'"
Set Rs=Server.CreateObject("Adodb.RecordSet")
rs.open sql,conn,3,2

另外你这个登陆验证不严密,容易被注入登录!接受变量是过滤一下就好了,例如:password=Replace(Trim(request("password")),"'","")

if not rs.eof then 改为 if rs.eof then 试试

确实没创建rs对象,此段语言应调整为:
sql="select * from book.huiyuan where username='"&username&"' and password='"&password&"'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,2

数据库链接代码为:
AccessDbUrl="/数据库目录/" 'Access数据库地址
Set Conn=Server.CreateObject("ADODB.Connection")
conn.Open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath(AccessDbUrl)&"/数据库名称.mdb"
<