Use these to jump around or read it all…
[My Poll]
[The Parts]
[My Assumptions]
[The HTML File]
[The CGI Script]
[Get It On the Server]
[Alter the Script]
This tutorial is a topic that people have been asking for, for some time. You, the surfer, log into a page and there’s a small poll waiting for you. You answer, click to submit, and up pop the total responses. It’s a pretty great effect.
As with anything on HTML Goodies, getting something to work is pretty easy. The hard part is that I have to write and understand how it works. This concept took a while because it does get a little difficult. The process requires a PERL CGI script to work. Thus, you have to be able to place CGI on your server or this won’t work for you.
Now, before many of you without CGI access ask, no. You cannot get this effect through HTML or JavaScript alone. The format here requires that something (a CGI, VBScript, or possibly an applet) write a file to keep track of all the answers. Without that “count” being kept – the concept is pretty much shot.
That said…let’s see it.
My Poll
The HTML Goodies
Life Affirming
Question:
Would you go
to the North Poll?
Yes
No
Maybe
Pretty cool, huh? I’m trying to teach myself PERL at the moment (12/22/99) and this is my first really big script. I had a little help with some of the more codey parts but the rest is pure me. You should have seen the dance I did when it worked for the first time. I could have won an award.
And before you write to tell me…yes, I know North Pole is spelled O-L-E. You see this is a “poll”, so I spelled “pole”, “poll”. It’s more of the pure comedy you have come to expect on the HTML Goodies site.
Thanks folks! I’m here all week! Tip your waitress!
The Parts
You’re going to require six files to make this effect run: the HTML document, the PERL Script, the poll.dat file, and three images.
Here are the first five:
- HTML Code
- joepoll.cgi
This is in HTML format. To get it in CGI format, while viewing, copy and paste the contents into a text editor and save as name.cgi or name.pl depending on your server’s preference. - pollred.gif
- pollblue.gif
- pollgreen.gif
There’s no real reason to give you the poll.dat file because you can easily make it yourself. Simply open your text editor. I suggest Notepad or SimpleText. Save a blank document as poll.dat. That’s it.
Make sure the document is blank. There can be no text on it at all. Those of you who use FrontPage or some other HTML assistant, don’t use it to do this. I promise it will add code. This document must be blank.
Now that I’ve driven that point into the ground, we’ll go on.
My Assumptions
I Assume You Have Access
As was stated at the beginning of this tutorial, I am assuming you have the ability to create, post and change modifications in a CGI-BIN on your server. If you are on a free server like Geocities, or a national pay-for like AOL or Compuserve, my bet is that you do not have access.
If you’re not sure if you have access, call your provider and ask. If you do not have access but want it, I’m afraid that it’s probably going to cost you a monthly ISP fee to get it. Smaller, local ISPs are the way to go if you want to play with CGIs.
I Assume You’ve Read One Of the Other CGI Tutorials
A good two years ago, I posted three tutorials on creating CGI-BINs and changing modifications to get PERL scripts to run. Since those three are there for the reading, I’m going to assume you’ve read at least one of them.
Each explain how to create a CGI-BIN, Telnet, change modification, and a couple other
funny terms I’ll use in the next run of paragraphs.
If you’re reading along and you run into something you don’t get, it’s probably because you need to start with a more basic, ground-up, tutorial. Try them in this order if you haven’t already:
Each is a true work of art…
The HTML File
Hopefully you’ve grabbed the HTML file from above. It’s a simple FORM format that can be used pretty much as is. The only line you’re concerned with is the first one: