w Web by Design: Using Transform to Create a Web Guestbook
IUPUI integrated images

Web by Design logo
Home Tutorials Resources Kudos CV

 

 

After over a decade of service to the web community, I have made the decision that Web by Design has served its purpose and lived a fruitful life. It is time to shutter the doors and move on. However, due to the fact that so many continue to reference this tutorial, I will keep it available for the near future.

Thank you for your support over the years. It has been a pleasure.

 

Using Transform to Create a Web Guestbook

This documentation was adapted from the Web Form with Transform 3.0: the Users' Guide. Transform is ONLY available to Indiana University.

This is a continuation of the Using Transform to Process Web Forms tutorial and covers how to create a web guestbook.

Creating a guestbook will result in three files:

Creating the Guestbook Form

A guestbook form generally does not contain as many fields as other web forms and usually does not require a name or other identifying data from the reader. For ideas on setting up your guestbook form, see the Sample Web Guestbook Form. For a refresher course in creating web forms, see Creating Web Forms.

Remember, these forms tutorials assume you are using the Transform forms utility, and that your web page is on the IUPUI champion.iupui.edu server in your home directory [~networkid] . Therefore, the action statement in your form (after Form method=…) will be:

http://www.iupui.edu/~networkid/directory/transform.cgi

Regarding the Javascript code for the current date:

At the top of the sample guestbook form, the current date is identified. This date is the result of Javascript. Current browser versions interpret JavaScript code so that only the actual date is displayed; therefore, you will be unable to look at my code to see how to create this effect. I have included the JavaScript code below. Place this code in place of the line you see in your file that indicates the current date.

NOTE: When you include Javascript code in your HTML file, it is important that the lines of the script not include "end of line" markers. Therefore, do NOT save your HTML file With Line Breaks; save the file as Text Only.

<script>

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","
June", "July","August","September","October","November","December")
document.write(""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"")

</script>

Completing the Guestbook form

After you have completed and viewed your form file for accuracy and layout,save the file with the name: guestbook_form.html. (The tutorial is using this name; you may name your file anything you like, as long as you remember that both the HTML file and the accompanying Transform template file have the same name.) Place it in your champion www/Forms directory that you created in previously during these tutorials (for a review of setting up your champion account in order to use Transform, see Installing Transform in your Account).

Return to top

Creating the Guestbook Form Template

For a review of Transform and the basic set-up of Transform template files, please review Using Transform to Process Web Forms. Remember,

As you create the template file, type the information requested exactly as it is shown in the sample below. In the case of italicized text, replace the information requested with your own information. For example type your E-mail address here should be replaced with the E-mail address to which you wish the form responses sent. (Even though you are creating a file that will be displayed on the web, Transform requires the E-mail response section.)

NOTE: You must be careful about the size of the file if you use the sample below. When data responses are appended in the manner described below, Transform must read through the entire file, then re-write it with each submission. If your guestbook grows very large, the response time will decrease dramatically. When you note that the response time has grown unacceptable, you should consider editing the guestbook.html to remove the older entries, placing them in a secondary file if you wish to retain them for reference or to link to them for your readers' benefit.

# begin template
# *email-response* section
*email-response*
To: type your E-mail address here
From: Guest
Subject: Guestbook Entry

# Notice that we are making the comments a required field.
# This will prevent you from receiving blank guestbook entries.

Please sign my guestbook: [req-comments]

# Now let's add a section which describes a successful form submission
# Note the *success-response* section header
# Since this response is being returned to the user's www browser it
# must be a correct HTML document and may contain any valid HTML tags.
*success-response*
<HTML>
<HEAD>
<TITLE>Thank you</TITLE>
</HEAD>
<BODY>
<P>Thank you for signing my guestbook!</P>

# This section defines where the guestbook itself resides on
# the web server. The guestbook file must reside in your main www directory
# so that Transform knows to make it a publicly read-able file.
# This path indicates that the guestbook file will be found up one
# directory level from the Forms directory. In other words, your
# www directory.

<P>To read other entries, enter <A HREF="../guestbook.html"><B>guestbook</B> now.</A></P>
</BODY>
</HTML>

# This error trapping section returns a message to the reader who
# attempts to submit a blank guestbook form entry.
*error-response*
<HTML>
<HEAD>
<TITLE>Oops. We need more info!</TITLE>
</HEAD>
<BODY>

You forgot to enter a comment: [comments]<BR>

<P>Use your browser's back button to return to the form.</P>
</BODY>
</HTML>

# The section appends the guestbook form entries to the guestbook itself.
# The append-before command specifies that data are entered before
# the horizontal rule (used to separate entries).
# This keeps your guestbook entries in reverse chronological order.
# The append-file-name command specifies the name and location of
# the guestbook file.
*append-response*
!append-before = "HR"
!append-file-name= ~type your networkid here/www/guestbook.html <P ALIGN=center><HR></P>

# !DATE captures the current date for your guestbook entry.

<P><B>On [!DATE] this comment was added:</B><BR>
<font color="#663300">      [comments]</font>
</P>

# end template file

Return to top

Creating the Guestbook

Although Transform will create the guestbook.html file when the first form submission is processed, you may prefer to create the file yourself so that you can affect the appearance of the guestbook. The *append-response* section of the template file controls how individual data entries/submissions will be added to the guestbook.html file. Submitted data will be appended to the file below any content you may have supplied. Our sample guestbook has a green background and a title.

Remember that the guestbook.html file must reside in your main www directory, not the Forms directory.

  1. Create a file named guestbook.html.

  2. To set up the background color and title, type:

    <HTML>
    <BODY BGCOLOR="#CCFFCC">

    <P ALIGN=center><B>WELCOME!</B></P>

Do not include any additional closing HTML tags because submitted forms will append BELOW the last item you type in this file, causing the closing HTML tags to be ABOVE the first form data.

Return to top

 

Return to Using Transform to Process Web Forms