Friday, July 30 2010

Technical Support
Account Management
Dialup Configuration
WWW Browsers
E-Mail
Newsgroups
Website Design Information
HTML Basics
 
HTML Structure
 
My First Webpage
Publishing your site
 
Using FTP
Advanced Resources
 
Password Protecting your site
 
Web Counter CGI
 
Form Mail CGI
 
Guestbook CGI
 
Simple Search CGI
 
Webboard CGI
Misc Configuration

CGI Scripts: Guestbook

What is a guestbook script? It's a page that allows users to leave their mark, akin to having fellow students sign your yearbook upon graduation.

To use the Guestbook CGI, you will need to create a guestbook directory directly under your public_html directory. You would then download and edit three HTML files to use by the Guestbook CGI. These are placed in the guestbook directory. Once this is done, create a link to the guestbook, and you are up and running with a Guestbook on your webpage.

Create the guestbook directory

The first step is to create the guestbook directory in your public_html directory.

  1. Using your favorite FTP client, login to our web server. Use your username and your password. Do not login anonymously. You cannot access your home directory under an anonymous login.
  2. Once you have logged in, you will be in your home directory. Change to your public_html directory.
  3. Use your ftp client's make directory command to create the guestbook directory. (mkdir is the command you should use with the UNIX and Windows '95, Windows '98 command line FTP program.)
  4. Change the file permissions of the guestbook directory to 777 (read/write/executable to all).

What follows is a sample command line FTP session.

ftp home.
Connected to home..
220 web2.tor.accglobal.net FTP server (NcFTPd 2.3.0) ready.
Name (home.:user): foo
331 User foo okay, need password.
Password: ********
230 User foo logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd public_html
250 CWD command successful.
ftp> mkdir guestbook
257 "/home/foo/public_html/guestbook" new directory created
ftp> CD guestbook
250 CDW command successful.
ftp>

If you are using a graphical FTP program, refer to your FTP client's user guide for assistance.

Download the sample HTML Files

The next step is to download the Guestbook zipfile that contains the three required guestbook files. You can use these as a base for your Guestbook web page or as a guide on how to modify your existing Guestbook webpage. (You can unzip this file with the winzip utility)

Edit each HTML file as required and upload them to your guestbook directory.

What each file does

guestbook.html Main guestbook file. This file is updated when a user adds their entry to the guestbook. The name of this file cannot be changed. The filename must be guestbook.html, all in lowercase, and html not htm as the file extension. File permissions should be set to 777 (world readable/writable/executable) for this file.
addguest.html The web form used to add entries to your guestbook.
guestlog.html The file updated with log entries of new additions to your guestbook. As with the guestbook.html file, this filename cannot be changed. File permissions should be set to 777 (world readable/writable/executable) for this file.

Updating guestbook.html

You may customize the guestbook.html file as much as you wish using the following guidelines:

  • All comments in the file are required. Do not remove them.
  • The order in which the comments appear are important. Do not rearrange them.
  • Once the guestbook is in use, we do not recommend editing the guestbook.html file. If the file is changed, it may fail to update the file correctly.

Updating addguest.html

The guestbook script relies on hidden HTML tags to get the necessary information to create the guestbook web page. addguest.html is the file used to update the guestbook. The following table provides a list of the tags contained in the file. Follow the link on the tag name for a detailed description of the tags and it's usage. For an example of how to insert the HTML form tags into your document, view the sample addguest.html file.

The following tags are used by guestbook in addguest.html:

Tag name Type What it does
username visible User's e-mail address
realname visible User's real name
url visible User's URL to home page
city visible User's city
state visible User's state or province
country visible User's country
comments visible User's comments
user hidden REQUIRED. Your user id or username. Should be in the format of user@ For compatibility with existing guestbooks, if the domain name is missing from the user id, @ will be added automatically
mail hidden Set to 1 if you want an e-mail message sent when an entry is added to your guestbook. The recipient tag must be completed for a message to be sent.
uselog hidden Set to 0 to disable guestbook logging into guestlog.html
linkmail hidden Set to 1 to enable linking of e-mail addresses to a mailto: URL. This will allow users to clock on a user in your guestbook to send an e-mail message to them.
separator hidden Set to 1 to use a line tag (<hr>) instead of a paragraph tag (<p>) to separate guestbook entries.
redirection hidden Set to 1 to automatically redirect the user's browser to the guestbook after an addition. Set to 0 to display a page telling the user the guestbook entry has been added.
entry_order hidden Set to 1 to have new entries added to the bottom of the guestbook. Set to 0 to have them added to the top. The default setting is to add entries to the top.
remote_mail hidden Set to 1 to have a form letter e-mailed to the user if they fill in their e-mail address. The recipient tag must also be set for this to be enabled. The default is no e-mail is sent.
line_breaks hidden Set to 1 to enable changing line break or newline characters into <br> tags. The default is not to change newlines.
recipient hidden This is your e-mail address. It is required for the mail and remote_mail tags to work.

Updating guestlog.html

While you can update guestlog.html, there is no real need to. This file is only updated if the uselog tag is set in the addguest.html file and is intended to be viewed by you, the web site designer. The information in this page shows who attempted to use your guestbook including any errors.

Guestbook Details

username

This is a visible tag that give the user a place to enter their e-mail address.

Syntax: <input type=text name="username">

[ top ]

realname

This is a visible tag that gives the user a place to enter their real name.

Syntax: <input type=text name="realname">

[ top ]

url

This is a visible tag that gives the user a place to enter their URL to their home page.

Syntax: <input type=text name="url">

[ top ]

city

This is a visible tag that gives the user a place to enter the city in which they live.

Syntax: <input type=text name="city">

[ top ]

state

This is a visible tag that give the user a place to enter the state or province in which they live.

Syntax: <input type=text name="state">

[ top ]

country

This is a visible tag that gives the user a place to enter the country in which they live. It is helpful to default this tag to Canada or United-States depending on where you expect most of your users to be located. This ensures they enter something in this field.

Syntax:
Without default: <input type=text name="country">
With default: <input type=text name="country" value="United-States">

[ top ]

comments

This is a visible tag (generally set as a textarea HTML tag) that gives the user a place to enter the comments that he/she wants to add to the guestbook.

Syntax: <textarea name="comments></textarea>

[ top ]

user

This is a required tag. If this tag is missing, the guestbook CGI will present the user with an error. Specify your user id for the user tag. This should be in the form of user@ . However, for compatibility with older websites/pages, if the domain name is left off the user tag, then @ will be added automatically.

Syntax: <input type=hidden name="user" value="foo@">

mail

If this option is set to "1", the the guestbook CGI will e-mail you when a new entry is made to your guestbook. The default for this option is not to send e-mail The recipient tag must also be defined for e-mail to be sent.

Syntax:
To enable send an e-mail on a new entry: <input type=hidden name="mail" value="1">
To disable sending an e-mail on a new entry (the default): <input type=hidden name="mail" value="0">

[ top ]/p>

uselog

This tag enables or disables logging to the guestlog.html file. Set this value to "0" to disable guestbook logging and to "1" to enable it. The default is to enable logging is uselog is not included in your addguest.html file.

Syntax:
To enable logging (the default): <input type=hidden name="uselog" value="1">T
To disable logging: <input type=hidden name="uselog" value="0">

[ top ]

linkmail

Setting this option to "1" enables user's e-mail addresses in the guestbook to be hyperlinked. This enables users to click on the e-mail address to send e-mail to that user. Set this to "0" to disable this feature. The default is not to hyperlink e-mail addresses.

Syntax:
To enable linkmail: <input type=hidden name="linkmail" value="1">
To disable linkmail (the default): <input type=hidden name="linkmail" value="0">

[ top ]

separator

Set to "1" to use the <hr> tag (line tag) and to "0" to use the <p> (paragraph) tag to separate guestbook entries. The default is to use the <hr> tag.

Syntax:
To use the line or <hr> tag (the default): <input type=hidden name="separator" value="1">
To use the paragraph or <p> tag: <input type=hidden name="separator" value="0">

[ top ]

redirection

Set to "1" to enable redirecting the user's web browser to the guestbook.html file after their entry is made. Set to "0" to display a result web page suggesting the entry was accepted. The default is to display a webpage, and not redirect the user's web browser.

Syntax:
To redirect the user's web browser: <input type=hidden name="redirection" value="1">
To not redirect the user's web browser: <input type=hidden name="redirection" value="0">

[ top ]

entry_order

Set to "1" to have new guestbook entries added to the top of the guestbook. Set to "0" to have new entries added to the bottom of the guestbook. The default is to have the new entries added to the bottom of the guestbook.html file.

Syntax:
To add new entries at the top: <input type=hidden name="entry_order" value="1">
To add new entries at the bottom: <input type=hidden name="entry_order" value="0">

[ top ]

remote_mail

This option, if set to "1", will e-mail the guestbook user a form letter, if they provided their e-mail address. Set this option to "0" to disable this feature. The default behavior is to not send a form letter.

Syntax:
To enable sending a form letter: <input type=hidden name="remote_mail" value="1">
To disable sending a form letter: <input type=hidden name="remote_mail" value="0">

[ top ]

line_breaks

This option controls whether the line breaks or newline character entered in the comments field are change to <br> HTML tags. Set this option to "1" to enable this feature. Setting it to "0" leave the comments field unchanged. The default is not to change the comments field. Not changing the newlines to <Br> HTML tags has the effect of placing the comments on one line with formatting of the text left up to the web browser.

Syntax:
To enable changing the comments field: <input type=hidden name="line_breaks" value="1">
To disable changing the comments field: <input type=hidden name="line_breaks" value="0">

[ top ]

recipient

Set this option to your e-mail address. This option is required if the mail or remote_mail options are set.

Syntax: <input type=hidden name="recipient" value="user@">

[ top ]

©2002, Isterra Services offered by Primus. All rights reserved.
Acceptable Use Policies
Rates and General Service Agreement