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"
%>