Access Services Software Help Center Policies Jobs

Creating a Guestbook

What is a guestbook?

The guestbook program allows you to create a form which visitors to your website can fill out, then displays the data entered by visitors on a page of your website. The data is handled by a program called a CGI script which runs on the Bruin OnLine web server.

Click here too see what a guestbook looks like.

Please Note: The guestbook is an advanced feature of the Bruin OnLine Web Service; familiarity with HTML tags is required. If you are unfamiliar with HTML, please consult out HTML reference page before attempting to create a guestbook.

Creating the Guestbook

In order to create a guestbook, you will need to create three separate files:

  1. An HTML document containing the form itself as well as a link to the CGI script to which the form data will be submitted. In the following example this file is called guest.html.
  2. A plain text configuration file containing the parameters for how and where the form data is to be posted. This file must always be called gbook.cfg.
  3. An HTML document to which the form data is to be posted. In the following example this file is called guestbook.html.

Step 1: Creating the guest registration form (guest.html)

Your guest registration form should be a regular HTML form. This form may be a page in itself, or may appear as part of a larger page.

To instruct the reader's web browser to submit the form data to the guestbook script, begin your form with the tag:

<form method="post" action="http://www.bol.ucla.edu/cgi-bin/guestbook.cgi">

This tag signifies that the successive information will appear on your web page as a form, and that the data collected by the form will be posted to the Bruin OnLine guestbook service CGI script (http://www.bol.ucla.edu/cgi-bin/guestbook.cgi).

Next, create the text fields for your form. For each field you must specify a label, the variable to be entered, and the size of the field. To create a field for the visitor's e-mail address, for example, enter

<p>E-mail address: <input type="text" name="email" size="25" /></p>

E-mail address is the text label for the field, email is the variable to be entered, and 25 is the number of characters the field will hold. The field will appear on your form like this:

E-mail address:

After creating all the text fields for your form, create the SUBMIT and RESET buttons which will appear at the bottom of the form. To create the SUBMIT button, enter

<input type="submit" name="submit" value="POST to the guestbook">

type="submit" signifies the function of the button; POST to the Guestbook is the label which will appear on the button (you may enter different text here if you wish).

To create the RESET button, enter

<input type="reset" name="reset" value="CLEAR the form" />

At the end of your guest registration form place the tag

</form>

Step 2: Creating the configuration file (gbook.cfg)

After creating the guest registration form, you must create a configuration file which will tell the CGI script the names of the variables you have included on the form and where to post the data collected, by the form.

The gbook.cfg file for a guest registration form with the variables name and email, for example, should look like this:

    GuestFile=guestbook.html
    ViewHead=header.html
    ViewFoot=footer.html
    HitNo=1
    EndConfig=Now
    $HITNO,No., ,<br>
    $DATE,Date:, ,<br>
    $TIME,Time:, ,<br>
    name,Name:, ,<br>
    homepage,Homepage:, ,<br>
    email,E-Mail Address:, ,<br>
    
GuestFile=guestbook.html This is the file which all the information is posted to. This is the file mentioned in Step 3.
ViewHead=header.html This file includes any HTML source that you want to appear on the submission page before the guestbook entry. If the file specified does not exist, a default one will be used.
ViewFoot=footer.html This file includes any HTML source that you want to appear on the submission page after the guestbook entry. If the file specified does not exist, a default one will be used.
HitNo=1 This is the hit number which you want your guestbook to start with.
EndConfig=Now Marks the end of the config data
$HITNO,No., ,<br /> Enters the Hit Number
$DATE,Date:, ,<br /> Enters the date submitted
$TIME,Time:, ,<br /> Enters the time submitted
name,Name:, ,<br /> Print "Name:" followed by a blank and the input $name from the guestform.html form and a line break
homepage,Homepage:, ,<br> Print "Homepage:" followed by a blank and the input homepage from the guestform.html form and a line break
email,Email Address:, ,<br> Print "Email" followed by a blank and the input email from the guestform.html form and a line break

Name the file gbook.cfg, and upload it to your public-html directory on the Bruin OnLine web server in ASCII format. Because the number of hits (HitNo) recorded in the gbook.cfg file is updated with each guestbook entry, once you have uploaded the file to the Bruin OnLine web server you must change the permissions so that everyone can read and write to the file. The gbook.cfg must be readable and writable by everyone so that the cgi script can change it after each entry is posted.

Note: UNIX (the operating system of the server on which the guest book script runs), unlike HTML, is case-sensitive; be sure that each command in the configuration file appears in the correct case. Take care not to enter any extra spaces or returns, as extra spaces and line breaks will appear as "garbage" text in your guestbook file.

Step 3: Creating the guestbook file

The last file you must create is the HTML file in which the guestbook data is displayed. In this example this file is called guestbook.html; be sure that the name you select matches the name you entered next to GuestFile= in the configuration file.

Enter whatever other information (title, graphics, background, other text, etc.) you wish into the guestbook file, then insert the following tag just before the page's closing </body> tag:

<!--GuestBook Starting Point-->

Because the guestbook file is updated with each entry, once you have uploaded the file to the Bruin OnLine web server you must change the permissions so that everyone can read and write to the file.

Guestbook troubleshooting checklist

  • Most server errors are due to incorrect permissions set for the gbook.cfg or guestbook.html file. Make sure that you have set the correct file permissions.
  • Make sure that your gbook.cfg file was uploaded in ASCII format. Most FTP clients are set to "BINARY" by default; check your FTP settings before uploading the configuration file.
  • Make sure that each command in the gbook.cfg file appears in the correct case, and that the file contains no extra spaces or line breaks.
  • If clicking the SUBMIT button has no effect, check the FORM METHOD tag to make sure that the URL for the CGI script is correct. Be sure that the SUBMIT button's TYPE attribute is set to submit.
  • If information from specific fields is not being posted, make sure that all variable names in the configuration file and the guest registration form file are spelled the same and use the same case. Remember that UNIX (unlike HTML) is case-sensitive; use lower-case letters for all variable names to prevent any confusion.