ASP制作简单留言本的问题,通过写入.txt文件存储数据实现不了。各位大哥帮忙看看,谢谢啦!

ristin 2009-12-22 11:15:27
通过两个文件来实现,message.asp文件代码如下:




<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
background-color: #ADD8E6;
}
-->
</style></head>

<body>
<form id="form1" name="form1" method="post" action="messagere.asp">
<p align="center">简单留言本</p>
<table width="493" height="212" border="1" align="center">
<tr>
<td width="120">姓名</td>
<td width="357"><input name="name" value="" /></td>
</tr>
<tr>
<td>主题</td>
<td><input name="title" value="" /></td>
</tr>
<tr>
<td height="84">留言</td>
<td><textarea name="word" id="textarea" cols="45" rows="5" ></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="button" id="button" value="提交" /> 
 
<input type="reset" name="button2" id="button2" value="重置" /> 
 <a href="message.htm">查看以前的留言</a></td>
</tr>
</table>
<p>  </p>
</form>
</body>
</html>
...全文
124 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ristin 2009-12-23
  • 打赏
  • 举报
回复

呵呵,谢谢各位的回答,问题解决啦!
ristin 2009-12-22
  • 打赏
  • 举报
回复
我只是想简单实现一下功能,在message.htm中实现留言的记录。
Equn 2009-12-22
  • 打赏
  • 举报
回复
数据存到文本文件中? 那挺麻烦的,不如搞个mdb数据库来的方便哦。
yan11cn 2009-12-22
  • 打赏
  • 举报
回复
建议存入数据库 便于操作
另外charset=utf-8 建议换成charset=gb2312
ristin 2009-12-22
  • 打赏
  • 举报
回复
messagere.asp文件代码如下:


<%
if request("name")="" then
Error="错误信息:姓名为必填字段,请填写留言者姓名"
'URL 地址栏中会出现的错误提示信息
Response.Redirect("message.asp? error="&error)
elseif request("title")="" then
error="错误信息:每篇留言必须有一个主题,请填写主题"
response.redirect("message.asp?error="&error)
elseif request("word")=""then
error="错误信息:留言内容不能为空,请填写内容"
response.redirect("message.asp?error="&error)
'如果没有填写名字和主题或者内容为空将仍停留在留言界面
end if
guest="留言人:"&request("name")&vbcrlf
guest=guest&"时间:"&now()&vbcrlf
guest=guest&"主题:"&request("title")&vbcrlf
guest=request("guest")&request("word")&vbcrlf
guest=repalce("guest")&request("word")&vbcrlf
guest=repalce(guest,"<","<")
guest=repalce(guest,">",">")
guest=repalce(geest,vbcrlf,"<br>")
dim i,str,strresult,strtmp
dim m
m=95
for i=1 to len(guest) step m
strtmp=mid(guest,i,m)&"<br>"
strresult=strresult & strtmp
next
guest=strresult
set file=server.createobject("scripting.filesystemobject")
application.lock
path=server.mappath("message.htm")
if file.fileexists(path) then
const forappending=8
set stream=file.opentextfile(path,8)
stream.writeline"<hr>"
stream.writeline guest
stream close
else
set stream=file.createtextfile(path)
stream.writeline"<body bgcolor=oldlace><br><a href='C:\Documents and Settings\Administrator\桌面'>返回首页</a><p>
</p>"
stream.writeline guest
stream.close
end if
application.unlock
response.redirect"message.htm"
'将已有的留言记录在一个名为message.htm的页面中%>
ender129 2009-12-22
  • 打赏
  • 举报
回复
你存在数据库里面多好啊 数据库里面提取也很方便 要为以后着想
zch889 2009-12-22
  • 打赏
  • 举报
回复
提示什么错误嘛?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧