我 在一个ASP的简易论坛程序,下面是index.asp的代码,请问我红色标注的 session("username")是怎么来的,是默认申明的一个session变量吗,如果是的话,那么我觉得应该用isEmpty()来检查它是否被初始化才对,也就是说写成:if isEmpty(session("username"))=false
<script language="JavaScript">
function newwin(url) {
var newwin=window.open
(url,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=380")
;
newwin.focus();
return false;
}
</script>
<%
'=============连接数据库===============
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.ConnectionString="driver={SQL Server};server=zhangbo;UID=sa;Database=Discuss"
Conn.Open
'============从表Content中读取用户数据==============
Set rs=Server.CreateObject("ADODB.Recordset")
Set rs.ActiveConnection = Conn
rs.CursorType = 3
'打开记录集
rs.Open "SELECT * FROM Content WHERE UpperId=0 ORDER BY IsTop DESC, LastAnswerTime DESC"
'设置每页记录数
rs.PageSize = 3
'读取参数Page,表示当前的页码
Page = CLng(Request("Page"))
'处理不合法的页码
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
%>
<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>
<style>
<!--
.main { font-size: 10pt }
-->
</style>
</head>
<body topmargin="0" background="images/Back.jpg" vlink="#000000" link="#000000">
<div align="center">
<center>
<table width="714" border="0" height="218" cellspacing="0" cellpadding="0">
<tr> <td height="112"><img border="0" src="images/Titlebar.jpg"></td> </tr>
<tr> <td height="29" class="main"> <div align="center" style="width: 735; height: 54">
<% If Session("UserName") = "" Then %>
<form method="POST" action="ChkPwd.asp" name="myform">
<p align="left" class="main"><font size="2">
<font color="#FF0000"><% If Session("Errmsg")="" Then %> 游客您好,请您登录或注册
<% Else
Response.Write(Session("Errmsg"))
Session("Errmsg")=""
End If
%> </font>
<img border="0" src="images/arrow.gif">
用户名:</font><input type="text" name="UserName" size="12">
密码: <input type="password" name="UserPwd" size="12"> <input type="submit" value="登录" name="B1">
<a href="UserAdd.asp" onclick="return newwin(this.href)">注册新用户</a>
</form>
<% Else %>
<table width=720> <tr> <td align="left" width=630><p class="main">欢迎光临,<%=Session("UserName")%> ,
<% If Session("UserName") = "Admin" Then %>
<a href=UserList.asp>用户管理</a>
<a href=UserEdit.asp?UserId=<%=Session("UserId")%> onclick="return newwin(this.href)">修改用户信息</a>
<a href=logout.asp>退出登录</a>
<% Else %>
<a href=UserEdit.asp?UserId=<%=Session("UserId")%> onclick="return newwin(this.href)">修改用户信息</a>
<a href=logout.asp>退出登录</a>
<% End If %>
</p> </td>
<td align="left"> <a href="newArt.ASP" onclick="return newwin(this.href)"><font color="#0000FF"><img border="0"
src="images/new.gif"></font></a> </td> </tr> </table>
<% End If %>
</div>
</td> </tr>
</center>
<tr> <td height="18" class="main"> <% Call ShowPage( rs, Page ) %></td></tr>
<tr> <td height="21" class="main"> <% Call ShowList( rs, Page ) %> </td></tr>
<tr> <td height="15"> </td></tr>
<tr> <td height="15"> <p align="center" class="main">本系统为<a href="#">数据库编程园地</a>版权所有
</td></tr>
</table>
</body>
[此贴子已经被作者于2006-11-6 9:40:01编辑过]