Haneng.com Simple Message Board production source program example

Source: Internet
Author: User
Tags time and date
Program Default.asp
-------------------------------
<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 ' the ' of the ' file '. Make sure that 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 is 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"
%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.