To read the article online, visit

Creating a Guestbook, Part 2

By Joshua Bengal

  • Read Part 1

  • In Part 1 we looked at the source code for AddGuest.html and Submit.asp, two Web pages that allowed users to add a new guestbook entry. In this part we will examine Guestbook.asp, the ASP page that displays the guestbook in its entirity.

    This file contains the header of our guestbook page (you know, that cheezy text we all love to put there, as well as any banners and titles we may want) and then writes out the contents of entries.dat. Note: If you wanted to make a nifty little "View my guestbook" link so people could see the entries without signing in, you would link it to this file.

    By now we should all be experts at basic file manipulation, so I'll just put this code here without explanation and see if you can handle it.

    Option Explicit
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    'declare variable
    Dim objFS, objFile, objFile2, entries, textstream
    'read guestbook entries into textstream
    Set objFS = Server.CreateObject ("Scripting.FileSystemObject")
    set objFile = objFS.GetFile(server.mappath("entries.dat"))
    set textstream = objFile.OpenAsTextStream(ForReading, -2)
    entries = textstream.ReadAll
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <body bgcolor=#000000 text=#FFFFFF link=#FFFFCC vlink=#FFFFCC alink=#FF0000>
    <font face=Verdana size=5> Guestbook </font>
    <font face=Verdana size=2><blockquote>
    <% response.write(entries) %>

    And there you have it, your own little ASP guestbook. In real life, I made mine a little more complex (I check to see if URL and email were entered, and if they were I linked the names and email address to them) but this is pretty much the basic idea. And stick my name (Joshua Bengal, for those who don't notice author's) somewhere in the code so I can feel proud.

    To see this guestbook in action, swing on over to and sign my guestbook. Have fun! If you have any questions/comments/praise/money, feel free to write me at

    Happy Programming!

    Related Articles

  • View the Guestbook in Action!
  • Read the FileSystemObject F.A.Q.
  • Another "Create a Guestbook" Article
  • Censoring User Comments in a Guestbook Scenario

  • Article Information
    Article Title: Creating a Guestbook, Part 2
    Article Author: Joshua Bengal
    Published Date: Thursday, June 29, 2000
    Article URL:

    Copyright 2018 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers