| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 307 人关注过本帖
标题:为什么这个留言簿只能显示一条留言
收藏  订阅  推荐  打印 
不想从修
Rank: 1
等级:新手上路
帖子:30
积分:450
注册:2005-5-3
为什么这个留言簿只能显示一条留言

近日 在学习一个留言簿程序的时候 在生成一个book.txt文件后 为什么在这个文件中只能有一条留言,后面的留言都将会被一一覆盖 反正就只有一条留言
book. asp的代码如下:
<%@ Language=VBScript %>
<%
name=Request.Form ("text1")
email=Request.Form ("text2")
subject=Request.Form ("text3")
memo=Request.Form ("textarea1")
if name="" or email="" or subject="" or memo="" then
Response.Write "输入框不能是空白"
Response.End
end if
'第一行显示内容
line1="留言人:"&name
line1=line1&string(5," ")
email="<a href=mailt"&email&">"&email&"</a>"
line1=line1&"email:"&email&"<br>"
'第二行显示内容
line2="主题:"&subject&"<br>"
'第三行
memo=replace(memo,vbcrlf,"<br>")
line3="<table border=0 bgcolor=#ffffff><tr><td>"
line3=line3&memo&"</td></tr></table>"
'第四行为留言时间
line4="时间:"&now()
on error resume next
set fso=server.CreateObject ("scripting.filesystemobject")
Application.Lock
filepath=server.MapPath ("book.txt")
oldfilepath=server.MapPath ("bookold.txt")
fso.MoveFile filepath,oldfilepath
set fin=fso.OpenTextFile (oldfilepath,true)
set fout=fso.CreateTextFile (filepath)
fout.writeline line1
fout.writeline line2
fout.writeline line3
fout.writeline line4
fout.writeline fin.readall
fin.close
fso.DeleteFile oldfilepath,true
Application.UnLock
Response.Redirect "showbook.asp"
%>
搜索更多相关主题的帖子: 留言簿  
2005-5-6 09:19
无根泉
Rank: 4
等级:高级会员
威望:3
帖子:850
积分:8848
注册:2004-11-4

if fso.fileexists(oldfilepath)=false then
fso.MoveFile filepath,oldfilepath
end if
set fin=fso.OpenTextFile(oldfilepath)' 在这在一加上true就会出错,郁闷
set fout=fso.CreateTextFile(filepath)
fout.writeline line1
fout.writeline line2
fout.writeline line3
fout.writeline line4
fout.writeline fin.readall
fin.close
fso.DeleteFile oldfilepath,true
我把下面的改成这样,在我这边测试成功,

我很菜,但我很努力!
2005-5-6 09:55
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.103595 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved