Creating a Guestbook
We'll start at the beginning. Between the double lines below is a simple guestbook.
Below is the program that posts it:
Just cut and paste it, if you'd like...
<H3> Sign In, Please...</H3>
<FORM METHOD="POST" ACTION="mailto:user@writemehere.com">
<B>Please enter your name:
</B><INPUT NAME="username" size="30"> <BR>
<B>and your e-mail address:
</B><INPUT Name="usermail" size="30">
<p>
<B>What do you think of my guestbook?</B>
<P>
<INPUT TYPE="radio" NAME=I_think_that VALUE="It's_Great">
It's Great!
<INPUT TYPE="radio" NAME=I_think_that VALUE="It_stinks">
It Stinks!
<INPUT TYPE="radio" NAME=I_think_that VALUE="You_stink">
You Stink!
<BR>
<INPUT TYPE="radio" NAME=I_think_that VALUE="I_stink">
I Stink!
<INPUT TYPE="radio" NAME=I_think_that VALUE="We_all_stink">
We All Stink!
<P>
<H3>Make any comments you'd like below:</H3>
<CENTER>
<TEXTAREA NAME="comment" ROWS=6 COLS=60></TEXTAREA>
<P>
<B>Thanks for your input</B>
<BR>
<INPUT TYPE=submit VALUE="Send it!">
<INPUT TYPE=reset VALUE="Start over">
</CENTER>
</FORM>
What you have above is a very simple guestbook setup using two text boxes, five radio buttons, and a text area. If what I just wrote is Greek to you, you really should read Writing Basic Forms first. I won't be explaining the above guestbook outside of implementing it to send mail. The input items are covered in the forms tutorial.
If all you want is a simple guestbook that sends mail to you -- boom. You're done. Just...
The following are two additions to the basic guestbook. These allow you to -maybe- change the output of your guestbook.
If you've set up your guestbook and the result arrives in your e-mail
box as a long line of strange text or as an attachment, this is for you!
Follow the same FORM command format as above, except add another
subcommand: ENCTYPE="text/plain". Like so:
<FORM METHOD="POST" ACTION="mailto:login@yourserver.net" ENCTYPE="text/plain">
The "ENCTYPE" command stands for Encryption Type. It's telling the server to return the mail as text only. If it works you'll get an output something like this:
Name=Joe Burns
Email=jburns@htmlgoodies.com
Comment=This thing works!
If you'd like to set aside your guestbook output from other e-mail you receive, you can do it simply by adding a subject to your e-mail address inside the FORM format command. Like so:
<FORM METHOD="POST" ACTION= "mailto:login@yourserver.net?subject=whatever subject you want" ENCTYPE="text/plain">
Notice that all I did was add a "?" right after the e-mail address and then "subject=." Please note you do not surround the subject in quotation marks. There is only one at the beginning of the mailto: command and one at the end of the subject line. That's it.
The format is to add "&cc=" and then the e-mail address of the person who should get the carbon copy. Thusly...
<FORM METHOD="POST" ACTION= "mailto:login@yourserver.net?subject=whatever subject you want&cc=joe@earthweb.com" ENCTYPE="text/plain">
This isn't always successful depending on browser version, but give it a shot. You should be able to list as many e-mail addresses as you like, separated by commas and no spaces, and all should get the guestbook output. Like so:
<FORM METHOD="POST" ACTION= "mailto:login@yourserver.net,joe@earthweb.com,bob@earthweb.com">
If you've made a bunch of forms, then you know that TEXTAREA boxes usually don't wrap the text. It just keeps rolling off the page. Well, fear not. Add this: WRAP="virtual" to your TEXTAREA boxes and the text will wrap right around. It looks like this:
<FORM>
<TEXTAREA COLS="50" ROWS="75" WRAP="virtual">
</FORM>
Instead of the dull, gray image button, allow your viewers to click on an image to submit your form. Go here for how it's done.
Now the fun part. If you attach the output of your guestbook to a CGI, you can do a great many things. For one, you can make it so the mail arrives in your box looking like regular e-mail without all the gibberish. (If you get the tip above to work, you probably won't need this.) You can also make it so a page comes up that thanks the person for sending e-mail. And you can also make a "graffiti wall" where people can post e-mail messages. I'll show you how to do each right here.
This is done inside the FORM command. Here's the FORM line from the guestbook above:
<FORM METHOD="POST" ACTION="mailto:user@emailaddress.com">
See the ACTION? It's telling the server what to do with the output (what
the viewer writes) of the form. In this case it is telling the server to send it
through the mail system.
The reason all the gibberish shows up is because that's actually what your
mail looks like to the computer. When you're using a nice mail program, all the
stuff is made to look like space, but when you send mail this way, all the stuff
is made visible.
Now look at this:
<FORM METHOD="POST" ACTION="cgi/email">
See how the ACTION is sending the information to something on my site named "email?" Notice it's in a directory named "cgi?" That's what I'm talking about when I say to attach your guestbook to a CGI. You send the output of the page to a CGI that manipulates it and offers output (if you wish).
Please note: You cannot attach to my CGIs through the above path. It does not exist. I made it up for demonstration purposes.
First off, you need to find out if you can place one of these on your
server.
You see... CGIs are more than just little text files. They are small
programs that do tricks, like manipulate e-mail data. The problem comes in that
CGIs must be sitting in an "activated" directory. This is a place that the
server knows where a little program sits, rather than just text.
You need to ask your Webmaster, service tech, or the person who takes your
checks each month if you are able to place your own CGIs. The easiest way is to
get the person to make you a sub-directory of their primary CGI directory. All
sub-directories carry the same properties as the higher-level directory. Or just
find out if you have the ability to activate your own directories