Web Site Hosting Features: Poll Manager Script


This tool will let you put a poll on your website and display the results.

Not yet a customer? Click here to compare our hosting packages to get access to the poll manager and all our other incredible features!


HTML Form names:

Form Method

action="/path/to/poll.cgi" method="POST" (The method must be post, or an error will be displayed.)

Poll Information

name="poll_id" type="hidden" REQUIRED (Value will contain the id of the current poll. This value will not be seen by users.)
name="poll_title" type="hidden" REQUIRED (Value will contain the poll's title. This value will be displayed to users, and should be descriptive of the poll.)
name="redirrect" type="hidden" OPTIONAL (Value will contain a fully qualified URL to which the user will be directed to after voting.)

Voting options

type="radio" name="vote" (at least 1) REQUIRED (This will be the means by which the users vote. The values will contain the answer to the poll. These will be displayed in the results page, and should be entered as you would like them displayed.)


<form action="/cgi-bin/poll.cgi" method="post">
<input type="hidden" name="poll_id" value="yesno">
<input type="hidden" name="poll_title" value="Yes, No or Maybe">
<input type="hidden" name="redirrect" value="http://yahoo.com">
<input type="radio" name="vote" value="No"> No <br>
<input type="radio" name="vote" value="Maybe"> Maybe <br>

<input type="submit" value="Vote!">

This form can be placed anywhere on your site, in any html page, and formatted however you like.

To display a poll:

Method One - SSI

To display the poll results directly on your webpage, you will first need to create an HTML document that contains your content and has a ".shtml" extension. This extension tells the webserver to parse "includes" and display the results of the "include".

In this example, "results.shtml" will be the example SHTML document.

------ START results.shtml PAGE--------
<!--#include virtual="/cgi-bin/poll.cgi?poll_id=yesno&ssi=1" -->
------ END results.shtml PAGE ---------

The above example will display the poll identified by "poll_id". In this case, it is our aforementioned "yesno" poll.

To display results via SSI (Server Side Includes), you must also give the script the parameter "ssi=1" or ssi="yes", as shown above.

The default color of the results bars is black. This can be changed by also passing in the "bar_color=COLOR" parameter. For example:

<!--#include virtual="/cgi-bin/poll.cgi?poll_id=yesno&bar_color=yellow&ssi=1" -->

The available colors are as follows:


Additional colors can also be added. All that needs to be done is to create a jpeg image that is 1 pixel X 1 pixel and of any color you choose. Upload it to the directory you specified as "$image_url" (yourdomain.com/images by default), in the format of YOURCOLOR_pix.jpg. If you create a 1x1 px. jpeg of the color chartruse, you would name it "chartruse_pix.jpg". Then, you can use that color.

<!--#include virtual="/cgi-bin/poll.cgi?poll_id=yesno&bar_color=chartruse&ssi=1" -->

Displaying links to past polls:

You can also include a list to past polls. Use the same method of including the "include" line, but use the following variables:

<!--#include virtual="/cgi-bin/poll.cgi?past_polls=1" -->

The "past_polls" variable will be given in this case, with a value of "1" or "yes".

This will link to the built-in function of displaying the poll results. With just the above link, the default colors format will be used. You can, however, give extra options to further customize the displayed results.

<!--#include virtual="/cgi-bin/poll.cgi?past_polls=1&bar_color=red" -->

Use the above include to link to results that display a red bar.

NOTE: For any SSI included poll data, you will need to do all the formatting within the page. Simply the raw html will be displayed with the includes, so putting them within a table or div would be a lot prettier.

CSS Support:

You have the option to either modify the default css style, or copy it and modify the copy. It is preferred to copy it and modify it so as to not loose the original copy if an error is made

Two CSS Styles are provided. The default black and white style, and a more colorful red and yellow one.

To use a custom css when displaying the links to past polls, as described above, try the following:

<!--#include virtual="/cgi-bin/poll.cgi?past_polls=1&bar_color=red&css=poll_yellow.css" -->

The above will create the links to the poll data that will be displayed using red bars, and the "poll_yellow.css" style sheet.

For the sake of example, you can use the following for the default style, even though it is not required:

<!--#include virtual="/cgi-bin/poll.cgi?past_polls=1&bar_color=red&css=poll_default.css" -->

Method Two - Direct link:

If you do not wish to use SSI, you can make a link directly to the current poll. Simply use this format:

<a href="/cgi-bin/poll.cgi?poll_id=yesno"> View Poll Results </a>

Again, you can pass in the bar color, and the css style.

<a href="/cgi-bin/poll.cgi?poll_id=yesno&bar_color=orange&css=poll_yellow.css"> View Poll Results </a>

When displaying the results this way, 25 random past polls will also be generated in a menu on the left-hand side of the page.

User configurable variables within the script (this requires that you edit the script itself):

# Full Unix Path to directory where the data files will be stored (not
# web accessible == better)
$data_dir = '/home/YOUR_USERNAME/poll_data';

# Absolute URL to grab images from (leave blank for root web '/')
$image_url = '/images';

# Absolute URL to grab CSS files from (leave blank for root web '/')
$css_dir = '';

# List of referers that are allowed to post to polls
@referers = (

# When the browser blocks the referer, do we want to allow a vote?
# 1=yes 0=no
$allow_empty_ref = 0;

# If set to 1, this value will disallow the creation of a new poll unless
# a file named "create.allow" is placed into $data_dir. This file should
# be created/uploaded whenever a new poll needs to be made. It will
# automatically be removed upon creation of the poll.
# secure = 1, not = 0
$more_secure = 1;

If $more_secure is set to 1, then you will not be able to create a new poll, unless you click the "Allow a new poll" button in the control panel first. Once a vote is posted to the poll, you will again be unable to create a new poll until you repeat the step above.

This is to keep hacker-type people from creating an unlimited number of polls. There are some other checks but the otherscan be bypassed rather easily.

PHP and MySQL is included in all our hosting packages