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:
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:
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:
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:
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>
Or actually, this means that the guestbook entry is inserted after the
<guestbook>
tag instead of in front of it.
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.
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:
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.
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>
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.
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-97Made in: Best found with: Best viewed with: