动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 Haneng.com的简单留言板制作源程序例子

作者来源: 
阅读 11854 人次 , 2000-10-5 

default.asp
-------------------------------
<HTML><BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<B>This is my guestbook. Use this form to submit your greeting:</B><BR>

<FORM METHOD="POST" ACTION="write.asp">
<INPUT NAME="new_line" TYPE="TEXT" SIZE=35>
<INPUT TYPE="SUBMIT" VALUE="Add greeting">
</FORM>
<BR><BR>
<%
  MyFile = "c:\guestbook.txt"

  'Opens the guestbook file if it exists
  Set MyFileObj=Server.CreateObject("Scripting.FileSystemObject")
  IF MyFileObj.FileExists(MyFile) THEN
    Set MyTextFile=MyFileObj.OpenTextFile(MyFile)

    'Reads a line, and outputs it
    WHILE NOT MyTextFile.AtEndOfStream
    %>
    <HR>
    <%=MyTextFile.ReadLine%>
    </HR>
    <%
    WEND

    'Closes the textfile
    MyTextFile.Close
  END IF' Does file exist
%>
<HR>
</BODY>
</HTML>

----------------------------




write.asp
----------------------------
<%
'Type in the path of the file to use. Make sure that the script has write access.
MyFile = "c:\guestbook.txt"

'Ready Scripting.FileSystemObject
Set MyFileObj=Server.CreateObject("Scripting.FileSystemObject")
'Opens textfile. 8 = add line to file, true = create if it doesn't exists
Set MyOutStream=MyFileObj.OpenTextFile(MyFile, 8, TRUE)

  'Writes the line to the file
  New_line = Request.Form("new_line")
  New_line = Server.HTMLEncode(New_line)
  'Adds the time and date it was posted
  New_line = "<I>Posted: " & NOW & "</I><BR>" & New_line
  MyOutStream.WriteLine(New_line)

'Closes the file
MyOutStream.Close

'Sends them back to the default page
Response.Redirect "default.asp"
%>  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:让Session对象在不同域名下实现共享
· 下一篇:日历源程序
· ASP 3.0高级编程(二十三)
· 从一个舆论调查的制作谈面向对象的编程思路(一)
· 一个可以自动创建多级目录的函数
· IIS5 UNICODE 编码漏洞的利用心得
· 人民币小写转换为大写


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077