<html>
<head></head>
<body>
<%
DB="123.mdb" '数据库路径和文件名,请修改引号中的文件名
'这一句很关键,不能删除
set conn=server.createobject("adodb.Connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB)
conn.Open connstr
%>
name=trim(request.Form("adminusername"))
pass=trim(request.Form("password"))
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10
response.Redirect"3.asp"
else
response.redirect"4.asp"
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>
数据表admin中有两项u_user u_pass 分别为123 123
无论输入什么,结果都为false
求解,谢谢了
------解决方案--------------------
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10
response.Redirect"3.asp"
else
response.redirect"4.asp"
end ifrs.close
set rs=nothing
conn.close
set conn=nothing
------解决方案--------------------
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10
response.Redirect"3.asp"
else
response.redirect"4.asp"
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
------解决方案--------------------
当然有问题啊
name=trim(request.Form("adminusername"))
pass=trim(request.Form("password"))
这两句话要放到<%%>中去,你直接放到外面,系统以纯文本处理,name和pass永远为空
------解决方案--------------------
- VBScript code
<% '你把代码格式写好点啊,看得烦 Dim DB, conn, rs, connstr, name, pass, sql username DB = "123.mdb" '数据库路径和文件名,请修改引号中的文件名 Set conn = Server.CreateObject("Adodb.Connection") connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB) conn.Open connstr name = Trim(Request.Form("adminusername")) pass = Trim(Request.Form("password")) Set rs = Server.CreateObject("Adodb.RecordSet") sql = "select * from admin where u_name='" & name & "' and u_pass='" & pass & "'" rs.Open sql,conn,1,3 If Not rs.EOF Then username = rs("u_name") Session("lifeuser") = username Session.Timeout = 10 Response.Redirect "3.asp" Else Response.Redirect "4.asp" End If rs.close conn.Close Set rs = Nothing Set conn = nothing %>