| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 375 人关注过本帖
标题:为什么我的留言本只能显示一条留言?哪里出错了?
只看楼主 加入收藏
lljiiina
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2012-3-30
结帖率:66.67%
收藏
 问题点数:0 回复次数:0 
为什么我的留言本只能显示一条留言?哪里出错了?
下面的代码只能显示最新的一条留言,请各位高手帮我看看究竟哪里出错了。谢谢!这个留言本共有三个文件:分别是161.2.asp、book.asp、showbook.asp。会不会是book.asp文件中的“fout.writeline fin.readall”这个语句出现了什么问题?

下面是显示的留言贴子:

数据库编程访问者留言簿

--------------------------------------------------------------------------------
留言人:2 Email 2
主题:2
2
时间:2012-3-23 7:59:13
--------------------------------------------------------------------------------

返回留言表单


以下是留言本的代码:
161.2.asp 的代码:
  <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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" />
<title>数据库编程留言本</title>
</head>
<body>
<table border=1 cellspacing=0 cellpadding=4 width=100% bgcolor="#d0d0ec">
   <tr>
      <td align=center><font size="+2" color="#000080"><b>数据库编程留言本</b></font></td>
   </tr>
</table>
<form action="book.asp" method="post">
   <table border=1 width=100%>
       <tr>
          <td><font color="#000080">姓名:</font></td>
          <td><input type="text" name="name" size=20></td>
       </tr>
       <tr>
          <td><font color="#000080">Email:</font></td>
          <td><input type="text" name="Email" size=40></td>
       </tr>
       <tr>
           <td><font color="#000080">主题:</font></td>
           <td><input type="text" name="subject" size=60></td>
       </tr>
       <tr>
           <td><font color="#000080">留言:</font></td>
           <td><textarea name="memo" rows=6 cols=60></textarea></td>
       </tr>
   </table>
   <div align="center">
      <center>
         <table width=100%>
            <tr align="center">
               <td><input type="submit" name="send" value="提交留言" style="font-size:9pt"></td>
               <td><a href="showbook.asp"><font style="font-size:9pt">浏览留言</font></a></td>
               <td><input type="reset" value="清除重写" style="font-size:9pt "></td>
            </tr>
         </table>
      </center>
   </div>
</form>
</body>
</html>


book.asp 的代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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" />
<title>无标题文档</title>
</head>
<body>
<%
'读取各输入框的数据
Name=request("Name")
Email=request("Email")
Subject=request("Subject")
Memo=request("Memo")
 
'检查各输入框是否输入有数据
if Name="" or Email="" or Subject="" or Memo="" then
   response.write"输入框不能为空白!"
   response.end '不再处理以下的程序
end if
 
'第一行包含“姓名”与“Email”
line1="留言人:"&Name
line1=line1&string(5," ")   '插入5个汉字空格
Email="<a href=mailto:"&Email&">"&Email&"</a>"
line1=line1&"Email "&Email&"<br>"

'第二行
line2="主题:"&Subject&"<br>"
'第三行为“留言”,先将留言中的换行符 vbCrlf 换成 <br>
Memo=replace(Memo,vbCrlf,"<br>")
'为了显示不同的背景颜色,采用表格输出
line3="<table border=0,brcolor=#00ffff><tr><td>"
line3=line3&Memo&"</td></tr></table>"
'第四行为留言“时间”
line4="时间:"&now()

on error resume next '忽略所有的错误
' 建立 FileSystemObject 对象
set fso=server.createobject("scripting.filesystemobject")
application.lock

'取得 book.txt 及 bookold.txt 的完整路径
filepath=server.mappath("book.txt")
oldfilepath=server.mappath("bookold.txt")
'将 book.txt 更名为 bookold.txt
fso.movefile filepath,oldfilepath
'打开 bookold.txt
set fin=fso.opentextfile(oldfilepath,true)
'建立 book.txt
set fout=fso.createtextfile(filepath)
'写入访问者留言
fout.writeline line1
fout.writeline line2
fout.writeline line3
fout.writeline line4
fout.writeline "<hr>"

'一次读取整个 bookold.txt,然后写入 book.txt
fout.writeline fin.readall
'关闭 bookold.txt
fin.close
'删除 bookold.txt
fso.deletefile oldfilepath,true
application.UnLock()
'将网页导至“浏览留言”的网页 showbook.asp
response.redirect"showbook.asp"
%>
</body>
</html>


showbook.asp 的代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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" />
<title>数据库编程访问者留言簿</title>
</head>
<body text="#000000" bgcolor="#ffffff">
<h2 align="center">数据库编程访问者留言簿</h2>
<hr width=100%>
<!--#include file="book.txt"-->
<a href="161.2.asp"><p align="center">返回留言表单</p></a>
</body>
</html>


[ 本帖最后由 lljiiina 于 2012-4-1 10:12 编辑 ]
搜索更多相关主题的帖子: 数据库编程 留言本 访问者 留言簿 Email 
2012-03-30 16:57
快速回复:为什么我的留言本只能显示一条留言?哪里出错了?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014856 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved