Here I will give a simple how-to for the use of the xs4all guestbook script

What it does
This script allows you to start a guestbook where visitors to your page can leave any comments. The comments will then automatically be added to the HTML file of your choice.

What you'll find here
Here you'll find an explanation that attempts to explain in a simple way how you can use this script to create your own guestbook on the xs4all web server. It will not be an in depth manual since such a thing already exists here or you can type man guestbook at the UNIX prompt.

Form basics
The guestbook makes of course use of forms. I've already given a lot of explanation about forms on the pages where I explain the mailto script so if you're not familiar with forms i suggest you look at those first maybe even try that script out first since it's much easier to use.

The guestbook
OK, what you can actually do with the script is this:

I'll describe each possibility by example.

A simple guestbook

   <form action=http://www.xs4all.nl/cgi-bin/guestbook method=post>
   Your Email: <input type=text name=from size=30><br>
   Your Homepage: <input type=text name=homepage size=30><br>
   <textarea name=body cols=60 rows=10></textarea><br>
   <input type=submit>
   </form>
This gives a simple guestbook form that looks like this:

Your Email:
Your Homepage:

OK, this works as you can see here but it looks crappy. You get everything on the same page and the layout isn't much either.

How this works The secret here is in the names you assign to the form fields. As you've probably seen in my explanation about the mailto script you can assign almost any name to a form field. Well, here you cannot do that so easily. The script looks for three names in the form:

from
This takes the name or email adres of the user that has filled in the form and puts it in the From line in the response.

homepage
When this is filled in the scripts creates a hyperlink to the url specified here.

Body
This is the field that contains the actual comment. This is also the field where you can do formatting to the entered comments. Default usage is of course to simply assign this name to the text box. However, the author of the script has built in the possibility to use variables. Since I promised to keep this simple I'll not go into too much details here but simply give some directions to use this.

Take a look at this:

    <guestbook reverse noline dontescapebody>
    <form action=http://www.your.domain/cgi-bin/guestbook method=post>
    Your Email address: <input type=text name=from size=30><br>
    Your comments:<br>
    <textarea name=text rows=10 cols=60></textarea><br>
    <input type=hidden name=body value=
    "<p>The comment is:</p><blockquote>${text}</blockquote><hr noshade>">
    <input type=submit value="Send!">
    </form>
As you can see here the name text has been assigned to the comment box. Then we get this:
<textarea name=text rows=10 cols=60></textarea><br> <input type=hidden name=body value= "<p>The comment is:</p><blockquote>${text}</blockquote><hr noshade>">

We still use the name text for the actual comment only now it has been assigned to a hidden field. A hidden field is a form field on which the user can have no influence. So how come the text that the user has entered is still added to the guestbook? Well, earlier we've used the name text for the response. We now call on this with this:<blockquote>${text}</blockquote>

What can I do with this?
Well, if you wanna keep it simple just replace the part within the quotes with your own HTML. For example if you wanna give the responses in red text you'd use this:

<textarea name=text rows=10 cols=60></textarea><br>
    <input type=hidden name=body value=
    "<p>The comment is:</p><font color=red>${text}</font><hr noshade>">

Well, I hope it has been clear to you so far. Now I'll discuss some of the other possibilities built into the script.

Arguments to the guestbook tag
The next list comes straight from the original manual. I think it is pretty clear already. The are all used within the guestbook tag like this: <guestbook reverse noline dontescapebody>

NoHost
This parameter suppresses the addition of the [remote.host] field in the From: line. If the from and homepage variables are also empty or not present, no From: line is generated at all.

NoDate
This parameter suppresses the Date: field that is output by default.

NoLine
This parameter suppresses the <HR> that normally terminates each guestbook entry.

Reverse
If this parameter is present, guestbook entries are added in reverse order, that means that the most recent additions are at the top.

Or actually, this means that the guestbook entry is inserted after the <guestbook> tag instead of in front of it.

DontEscapeBody
Normally, all variables received from the script are ``escaped'' such that characters like & and < do not cause harm in your file, but instead show up as entered by the user. This among others prevents people from inserting jokes like <img src=> or <javascript> tags to your guestbook.

Use this parameter to turn this feature off for the body variable exclusively. You usually combine this with a predefined body variable, like the one in the example of the body explanation.

DontEscape
This is like the previous parameter, except that it turns off escaping for all variables. Use this with extreme caution, users will be able to easily add images or java scripts to your guestbook.

Required fields, next pages and further customizing
The script also has the possibilities to further customize your guestbook. You can make certain fields mandatory to fill in. This is how you do it:

<input type=hidden name=required value=body>

For the value you can enter the names of all the fields that you want the user to fill in.

NOTE!
If one of the required fields is empty the script returns a simple error message. This error message doesn't give much information about why the error occured. Users may think that your guestbook is broken.

A way to overcome this is by adding a special error message to the script. (you could of course use the JavaScript I described in the mailto pages)

Anyway, here's what the manual says about it:

missing
If a variable mentioned as required is blank, then by default a simple error message is returned. Setting this variable allows you to customize the error message. The value of the missing variable should be a (possibly relative) URL to the page that contains the error message.

If the URL contains a % character, then that character is replaced with the name of the variable that is missing. So, for example, if you add these lines to your form:

    <input type=hidden name=required value="from,body">
    <input type=hidden name=missing value="missing_%.html">

The if someone leaves the from field blank, then the contents of missing_from.html will be displayed. Similarly for the body field and missing_body.html. Note that the first variable that is found empty, causes the corresponding page to be displayed. In this case, if both fields are empty, missing_from.html would be displayed, because from is the first field checked.

Of course this does mean making seperate HTML files for each required field.

Having the entries in another file
Yes, as I said earlier, this is possible. Here's how:

    <form action=http://www.www.xs4all.nl/cgi-bin/guestbook/guestbook.html
     method=post>

Where guestbook.html is the file where you want to have the reactions. I advice you to have both the file with the form and the one with the responses in the same directory (map to you Windows 95 users)just to make things easier on yourself.

File permissions
Most errors with scripts like this one aren't made in the HTML but in the file permissions. The trick here is to give the script permission to actually write the contents of the form to a file. UNIX users will of course know what I mean but PC users have to pay attention to this.

  1. start up your telnet program
  2. connect to xs4all.nl go to your www directory with the command cd WWW(remember that UNIX is case sensitive!)
  3. type the following chmod 606 response.htm where response.htm is the file that contains the guestbook responses.

Other things
Well, this should be enough to get you going on your own guestbook. If you got any questions or comments feel free to mail me.

Page maintained by Jeroen Wijnands. Mail: wijnands@xs4all.nl
This update: 25-07-97

Made in:
Best found with:
WebFerret
Best viewed with: