那位大侠帮我看看这段程序asp的错在那里

来源:百度知道 编辑:UC知道 时间:2024/05/22 12:16:57
<!-- #include file="conn.asp" -->
<%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.createobject("adodb.recordset")
sqlc="select * from info where username='"&request.Form("username")&"' and password='"&request.Form("password")&"'"
rsc.open sqlc,conn,1,1
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
set rsc=nothing
response.Redirect("index.asp")
'如果用户不存在,session("username")为空
%>
登陆页面<form name="form1" method="post" action="http://www.rfpchina.org/bbs/login.asp">
<tr>
<td><div align="right">用户名:<&

<!-- #include file="conn.asp" -->
<%
'打开数据库判断用户是否存在,info为表名,username为字段名
set rsc=server.CreateObject("adodb.recordset")
rsc.Open "select * from info where username='"&request.Form("username")&"' and password='"&request.Form("password")&"'" ,conn,1,1
if not(rsc.bof and rsc.eof) then
session("username")=rsc("username")
session("password")=rsc("password")
session.Timeout=30
rsc.Close
set rsc=nothing
response.Redirect("index.asp")
else
response.write "<script LANGUAGE='javascript'>alert('对不起,登陆失败!');history.go(-1);</script>"
end if
'如果用户不存在,session("username")为空
%>

这样写吧!以我的思想的.你这样的程序的很容易出错的.
前面最好还要检查是否输入为空
不懂再Q我

打开记录集之后,应该是用 If rsc.eof then 来判断一下记录集是否为空,这样就知道验证成不成功了。如果验证不成