在同一个页面,为什么这个值在读取留言的时候可以显示,在填加留言的时候就不行呢
这个是Userincly.asp 这个文件的代码————————————————————————————————————————
<%
id=CheckStr(Trim(request("id")))
If ID="" then
Response.write"<script>alert(""不正确的ID"");location.href=""Index.asp"";</script>"
end if
dim js
set rs=server.CreateObject("ADODB.RECORDSET")
sql="select * from pcook_user where id="& id &""
rs.open sql,conn,1,1
js = rs("userName")
rs.close
set rs=nothing
%>
————————————————————————————————————————
留言页面的文件是 guestbook.asp 代码如下
————————————————————————————
<!--#include file="Inc/conn.asp"-->
<!--#include file="Userincly.asp"-->
<!--#include file="Inc.asp"-->
<!--#include file="Inc/function.asp"--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<%=Sitekeywords%>" />
<meta name="description" content="<%=Sitedescription%>" />
<link href="<%=SitePath%>images/css<%=css%>.css" type=text/css rel=stylesheet>
<link rel="shortcut icon" href="<%=SitePath%>images/myfav.ico" type="image/x-icon" />
<title>留言本 <%=SiteTitle%></title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>
<%=Head%>
<%=Menu%><div class="mw">
<div id="nw_left">
<div id="web2l">
<h5>您现在的位置:<a href="Index.asp">首页</a> >> 查看留言 <span><a href="?ac=add">签写留言
</a></span> 如果技术方面交流的话,请在程序讨论区提交。 </h5>
<div id="content">
<%If request("ac")="" then%><ul>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from pcook_Guestbook where yn=1 and jiaoshi='"+js+"' order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write("没有")
else
dim currentpage
maxperpage=10 '信息显示条数
rs.pagesize=maxperpage
currentpage=request.querystring("page")
if currentpage="" then
currentpage=1
elseif currentpage<1 then
currentpage=1
else
currentpage=clng(currentpage)
if currentpage > rs.pagecount then
currentpage=rs.pagecount
end if
end if
if not isnumeric(currentpage) then
currentpage=1
end if
dim totalput,n
totalput=rs.recordcount
if totalput mod maxperpage=0 then
n=totalput\maxperpage
else
n=totalput\maxperpage+1
end if
if n=0 then
n=1
end if
rs.move(currentpage-1)*maxperpage
i=0
w=1
NoI=currentpage*maxperpage-maxperpage
do while i< maxperpage and not rs.eof
NoI=NoI+1
%>
<li>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%" height="25" valign="middle" class="bgf7f7f7"><font color=blue><%=NoI%>.</font><%If year(rs("AddTime"))
&"-"&month(rs("AddTime"))&"-"&day(rs("AddTime"))=""&date&"" then Response.Write("<img src=""images/news.gif"" align=absMiddle
title=""新留言...""> ") end if%><font color=red><%=rs("Title")%></font></td>
<td class="bgf7f7f7"><%=left(rs("UserName"),6)%> <%=rs("AddTime")%> IP:<a href="http://www.
IP=<%=rs("AddIP")%>" target="_blank"><%=rs("AddIP")%></a><%=js%></td>
</tr>
<tr>
<td colspan="2" class="gcontent"><%=dvHTMLEncode(rs("Content"))%></td>
</tr>
<%if rs("ReContent")<>"" then%>
<tr>
<td colspan="2" style="padding:5px 20px;line-height:20px;font-size:13px;color:#174BAF"><hr><font color=red>管理员回复:
</font><%=rs("ReContent")%><br><font color="#cccccc">(回复时间:<%=rs("ReTime")%>)</font></td>
</tr>
<%end if%>
</table>
</li>
<%
i=i+1
w=w+1
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
</ul>
<div id="page">
<ul>
<%k=currentpage
if k<>1 then%>
<li><a href="Guestbook.asp">首 页</a></li>
<li><a href="?Page=<%=k-1%>">上一页</a></li>
<%else%>
<li><span>首 页</span></li>
<li><span>上一页</span></li>
<%end if%>
<%
yw1=currentpage-2
if yw1<1 then
yw1=1
end if
yw2=currentpage+2
if yw2>n then
yw2=n
end if
for i = yw1 to yw2
if i = currentpage then%>
<li><span><font color="#ff0000"><b><%=i%></b></font></span></li>
<%else%>
<li><a href="?Page=<%=i%>"><%=i%></a></li>
<%
end if
next
%>
<%if k<>n then%>
<li><a href="?Page=<%=k+1%>">下一页</a></li>
<li><a href="?Page=<%=n%>">尾 页</a></li>
<%else%>
<li><span>下一页</span></li>
<li><span>尾 页</span></li><%end if%>
<li><span>页次:<%=currentpage%>/<%=n%>页 共<font color="#009900"><b> <%=totalput%> </b></font>条记录 <%=maxperpage%>条/
页</span></li>
</ul>
</div><%elseif request("ac")="add" then
%>
<script language=javascript>
function chk()
{
if(document.form.UserName.value == "" || document.form.UserName.value.length > 8)
{
alert("不能提交留言,你的大名为空或大于8字符!");
document.form.UserName.focus();
document.form.UserName.select();
return false;
}
if(document.form.title.value == "" || document.form.title.value.length > 15)
{
alert("不能提交留言,你的留言标题为空或大于15个字符!");
document.form.title.focus();
document.form.title.select();
return false;
}
if(document.form.content.value == "")
{
alert("请填写留言内容!");
document.form.content.focus();
document.form.content.select();
return false;
}
if(document.form.code.value == "")
{
alert("请填写验证码!");
document.form.code.focus();
document.form.code.select();
return false;
}
return true;
}
</script>
<form onSubmit="return chk();" method="post" name="form" action="?ac=post">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff">
<tr>
<td height="30" class="adgs">大名:
<input name="UserName" type="text" id="UserName" value="请正确填写你的姓名" maxlength="10"
style="width:400px;border:1px solid #ccc;"></td>
</tr>
<tr>
<td height="30" class="adgs">给<%=js%>用户留言:
<input name="js" type="text" id="js" maxlength="15" value="<%=js%>" style="width:40px;border:1px solid
#ccc;"></td>
</tr>
<tr>
<td height="30" class="adgs">主题:
<input name="title" type="text" id="title" maxlength="15" style="width:400px;border:1px solid #ccc;"></td>
</tr>
<tr>
<td height="15" class="adgs">内容:
<textarea name="content" cols="30" rows="6" id="content" style="width:400px;border:1px solid
#ccc;margin:0;padding:0;height:200px;"></textarea></td>
</tr>
<tr>
<td height="30" class="adgs">验证码:
<input name="code" type="text" id="code" size="8" maxlength="5" style="border:1px solid #ccc;"/>
<img src="Inc/code.asp" border="0" alt="看不清楚请点击刷新验证码" style="cursor : pointer;"
onClick="this.src='Inc/code.asp'"/>
</td>
</tr>
<tr>
<td height="30" align="center"><input type="submit" name="Submit2" value=" 发 布 "></td>
</tr>
</table>
</form>
<%elseif request("ac")="post" then
dim UserName,Title,Content,jiaoshi
UserName = trim(request.form("UserName"))
Title = trim(request.form("Title"))
js = trim(request.form("js"))
Content = request.form("Content")
mycode = trim(request.form("code"))
if mycode<>Session("getcode") then
Response.Write("<script language=javascript>alert('请输入正确的认证码!');javascript:history.back();</script>")
Response.End
end if
if Instr(Content,"傻B")>0 or Instr(Content,"操你妈")>0 or Instr(Content,"胡锦")>0 or Instr(Content,"江泽")>0 or
Instr(Content,"娘")>0 or Instr(Content,"[url")>0 or HasChinese(Content)=false then
Response.Write "<script language=javascript>alert('请不要乱发信息,谢谢!');javascript:history.back();</script>"
Response.End
end if
set rs = server.CreateObject ("adodb.recordset")
sql="select * from pcook_Guestbook"
rs.open sql,conn,1,3
if UserName="" or Title="" or Content="" then
response.Redirect "Guestbook.asp?ac=add"
end if
rs.AddNew
rs("UserName") =UserName
rs("Title") =Title
rs("js") =js
rs("Content") =Content
rs("AddIP") =Request.ServerVariables("REMOTE_ADDR")
If bookoff=1 then
rs("yn") =0
else
rs("yn") =1
end if
rs.update
If bookoff=1 then
Response.Write("<script language=javascript>alert('恭喜你,留言成功,但需要管理员审核后才能显示出
来!');this.top.location.href='Guestbook.asp?id="&id&"';</script>")
else
Response.Write("<script language=javascript>alert('恭喜你,留言成功');this.top.location.href='Guestbook.asp?
id="&id&"';</script>")
end if
rs.close
Set rs = nothing
end if%>
</div>
</div>
</div>
<div id="nw_right">
<div id="web2r">
<h5>图片文章</h5>
<ul>
<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 3 ID,Title,Images,Content from pcook_Article where yn = 0 and Author='"+js+"' and Images<>'' order
by DateAndTime desc,ID desc"
rs1.open sql1,conn,1,3
NoI=0
If Not rs1.Eof Then
do while not (rs1.eof or err)
NoI=NoI+1
%> <li><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80" height="80" align="center" style="border:0px solid #ccc;padding:5px;"><a class="photo1" href="List.asp?
ID=<%=rs1("ID")%>"><img src="<%=SitePath%><%=SiteUp%>/<%=rs1("Images")%>" width="75" height="75" title="<%=rs1("Title")%>"
style="border:0px solid #ccc;padding:5px;"></a></td>
<td style="line-height:20px;padding: 0 5px;"><a href="List.asp?ID=<%=rs1("ID")%>"><%=left(LoseHtml(rs1("Content")),60)%
>...</a></td>
</tr>
</table>
</li>
<%
rs1.movenext
loop
else
Response.Write("没有图片文章")
end if
rs1.close
set rs1=nothing
%> </ul>
</div>
<div id="web2r">
<h5>推荐文章</h5>
<ul id="list10">
<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 10 ID,Title,TitleFontColor from pcook_Article where yn = 0 and Author='"+js+"' and IsHot=1 order by
DateAndTime desc,ID desc"
rs1.open sql1,conn,1,3
NoI=0
If Not rs1.Eof Then
do while not (rs1.eof or err)
NoI=NoI+1
%> <li>·<a href="List.asp?ID=<%=rs1("ID")%>"><%if rs1("TitleFontColor")<>"" then Response.Write("<font
style=""color:"&rs1("TitleFontColor")&""">"&rs1("Title")&"</font>") else Response.Write(""&rs1("Title")&"") end if%></a></li>
<%
rs1.movenext
loop
else
Response.Write("没有推荐文章")
end if
rs1.close
set rs1=nothing
%> </ul>
</div>
</div>
</div>
<%=Copy%></body>
</html>
--------------------------------------------------------------
表红的地方。为什么第一个js的值可以读取出来
第二个js的值,就变成空的。
还有点下一页的时候,希望显示的还是和用户相关的。而不是把所有的数据读取出来
非常感谢高手解答!
[[it] 本帖最后由 bichaoguo 于 2008-9-19 12:47 编辑 [/it]]