以下代杩:检测不到用户名(login),始终按空用户在执行!
我需要实现:只有用户为chen时才能访问以下信息!
环境是用asp访问的MYSQL数据库!
谢谢!
<!--#include file="conn.asp"-->
<%
set rst=server.createobject("adodb.recordset")
sql="select * from ss_users order by id desc "
rst.open sql,conn,1,1
%>
<%
if session("login")<>"chen" then
response.write "您无此权限"
response.end
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>用户查询</title>
<link rel="stylesheet" href="style.css">
</head>
<body topmargin="0">
<div align="center">
<center>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="980" cellspacing="0" cellpadding="0">
<%
if Not(rst.bof and rst.eof) then'判别数据表中是否为空记录
NumRecord=rst.recordcount
rst.pagesize=50
NumPage=rst.Pagecount
if request("page")=empty then
NoncePage=1
else
if Cint(request("page"))<1 then
NoncePage=1
else
NoncePage=request("page")
end if
if Cint(Trim(request("page")))>Cint(NumPage) then NoncePage=NumPage
end if
else
NumRecord=0
NumPage=0
NoncePage=0
end if
%>
<table border="1" width="980" bordercolorlight="#000000" cellspacing="0" cellpadding="5" bordercolordark="#FFFFFF">
<tr>
<td width="71" bgcolor="#EBE9FE" align="center">ID</td>
<td width="78" bgcolor="#EBE9FE" align="center">用户名</td>
<td width="50" bgcolor="#EBE9FE" align="center">EMAIL</td>
</tr>
<%if Not(rst.bof and rst.eof) then
for i=1 to rst.pagesize
%>
<tr>
<td width="71" align="center"><%=rst("id")%></td>
<td width="50" align="center"><%=rst("login")%></td>
<td width="30" align="center"> <%=rst("email")%></td>
</tr>
<% rst.movenext
if rst.eof then exit for
next
else
response.write "<tr><td colspan=13><marquee scrolldelay=120 behavior=alternate>没有找到任何记录!!!</marquee></td></tr>"
end if
rst.close
set rst=nothing
%>
</table>
</table>
</div>
</center>
</body>
</html>
以下是CONN.asp的代码:
<%
set conn=server.createobject("adodb.connection")
connstr="driver={mysql odbc 3.51 driver};server=localhost;database=123;uid=123;password=123;stmt=set names 'gbk'"
conn.open connstr
%>
------解决方案--------------------
session("login")="chen"