<% ' If the script doesn't have anything posted to it we display the form
' otherwise we process the input and append it to the guestbook file.
If Request.Form.Count = 0 Then
' Display the entry form. %>
Sign Our Guestbook:
Messages from our Guests::
<%
Else
' Log the entry to the guestbook file
Dim objFSO 'FileSystemObject Variable
Dim objFile 'File Object Variable
Dim strFile 'Location of the text file.
Dim DateTime 'The date and the time.
DateTime = Now() 'This puts in the date and the time at the server.
strFile = Server.MapPath("guestbook.txt")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Open the TextFile (FileName, ForAppending, AllowCreation)
Set objFile = objFSO.OpenTextFile(strFile, 8, True)
objFile.Write ""
objFile.Write Server.HTMLEncode(Request.Form("name"))
objFile.Write ""
objFile.Write " "
objFile.Write Server.HTMLEncode(Request.Form("comment"))
objFile.Write " ["
objFile.Write Server.HTMLEncode(DateTime)
objFile.Write "]"
objFile.Write "
"
objFile.WriteLine "" 'Puts in a new line.
' Close the file and dispose of our objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
' Tell people we've written their info
%>
Your comments have been written to the file!
Back to the guestbook.
Back to Adamson House home page.
<%
End If
%>