gb -- guest book example for form-submit

Overview

This presents an example use of MV Communications's form-submit utility to maintain a guestbook. This automatically maintains a guest list -- a record of information submitted by users who are entering data voluntarily into the guestbook. The guestbook can be viewed at any time.

Note that this information represents examples only, and any HTML and other data here may be skeletal; e.g. to the HTML given here you might want to add icons and colors, and flesh out the structure of the document.

This guestbook facility uses the "log-into" function of form-submit, which causes form results to be appended to a specified file. A template file provides the form by which this information is appended.

This example assumes that the guestbook is being used by J. Random User, who has a Web page at http://www.mv.com/ipusers/jruser . J. Random has created a directory forms for various forms, including this one; and in this directory there are the following files relating to the guestbook:


gb.html -- the HTML form

This is the form that the submitter fills in in order to add information to J. Random's guestbook. It defines fill-in fields and tags for the submitter's name, email address, home town, a URL, and any comments.

    <title> Guest Book Registration </title>
    
    You may enter my <a href=guests.html> guest book </a> by
    filling out the form below.
    
    <form ACTION="/cgi-bin/form-submit/ipusers/jrusers/gb/gb" method="post"> 
    
    <hr>
    Your name:<br>
    <input name="name" type="text" size=60> <br>
    
    <p>
    Your email address:<br>
    <input name="email" type="text" size=60> <br>
    
    <p>
    Your homepage URL:<br>
    <input name="url" type="text" size=60 value="http://"> <br>
    
    <p>
    Your home town:<br>
    <input name="hometown" type="text" size=60> <br>
    
    <p>
    Any comments?<br>
    <textarea name="comments" COLS=60 ROWS=8></textarea><br>
    
    <p>
    <input type="submit" value="Sign Guestbook">
    <input type="reset" value="Clear"> 
    </form>
    

The most important line is the reference to the form-submit utility:

    <form ACTION="/cgi-bin/form-submit/ipusers/jrusers/forms/gb" method="post"> 

Here, the argument /ipusers/jrusers/forms gives the path from the top of the WWW tree to J. Random's forms directory, and the final element gb identifies the form to be used. Given this, form-submit will take its directions from a file named gb.submit in that forms directory.


gb.submit -- the definitions file for form-submit

The gb.submit file tells form-submit how to proceed with processing the form submitted from gb.html .

    # submit file for guestbook form
    
    Tag-Required:	name
    
    Tag-Default	hometown	""
    Tag-Default	comments	""
    
    Log-into:	guests.html
    Log-from:	gb.template
    
    Return-document:	gb-done.html

This file directs that the submitter's name must be entered; that some fields, if omitted, will be defaulted to blanks (this is to make sure that there is a translation, even if blank, for those tags, since they are always included in the guestbook). It specifies that the results should be appended to a file named guests.html using the file gb.template as a model. That file (the template file) contains form-submit style substitutions so that the actual submitted information can be saved in the desired format. Finally, the gb.submit file says that when the form is successfully processed, a file gb-done.html should be returned to the submitter as a confirmation page.


guests.html -- the guestbook

The guestbook itself, guests.html, starts off as a basic HTML file containing some introductory paragraphs. As information is submitted via gb.html and forms-submit, this file grows to include the guest signature information. Here is a sample of how guests.html might begin.

    <title> J Random User's guest book </title>
    
    <CENTER><B><I>JR's guest book</I></B></CENTER>
    
    <p>
    These people have signed my guestbook.
    <a href=gb.html>You can too!</a>
    <p>
    <i>If you've been here before, you may need to reload to see new entries.</i>
    <p>

gb.template -- a template for appending to the guestbook

The gb.template file is identified in the gb.submit control file as the file that will be appended to the guestbook each time a submission is made. This template file has the appropriate forms-submit substitution strings so that the input data can be included in the guest book.

    <hr>
    ~?~:url==yes ~{-
    Name: <a href=~url>~name</a><br> ~}{-
    Name: ~name<br> ~}
    ~?~:email==yes ~{-
    Email: <a href=mailto:~email>~email</a><br>
    ~}-
    Submitted: ~$DATE+"%A %B %e, %Y"<br>
    Hometown: ~hometown <br>
    Comments: <i>~comments</i><br>

The first few lines:

    ~?~:url==yes ~{-
    Name: <a href=~url>~name</a><br> ~}{-
    Name: ~name<br> ~}

enclose the submitter's name in an HTML link reference if a URL was included, and without the link if there was no URL. Similarly, the Email line is only produced if an email address was specified; it is wrapped in a "mailto" link. The Hometown and Comments lines could also be suppressed in the same way if not submitted.

gb-done.html -- the confirmation file returned to the submitter

This is simply a page that is returned to the submitter after the form has been processed.

    <title>Confirmation</title>
    
    <h3>Thank You</h3> <p> 
    
    Thank you for signing my guest book.
    Please use your "back" function to return.