Simple Poll using PHP and MySQL
Bug fix release v 2.1; October 30, 2008
This script has been thoroughly updated as of April 14th, 2008. Subscribe to my blog by RSS or by email to be notified of further major updates, or view the changelog.
Download the MySQL/PHP poll zipped package now. Current version: v.2.
Script has been downloaded 2832 times since April 14th, 2008.
View an example implementation of the poll script.
Previous version of this script was downloaded 3607 times between May 25, 2006 and April 14th, 2008.
Find this useful? Encourage it! Make a donation.
Version 2 of this script is a massive rewrite of the previous version, and has significantly added to the ease of installation, poll management, and use. As a result, it is not possible to upgrade from a prior version to this version — the entire structure of the software has been rewritten.
Feel free to contact me with any comments concerning ease of use, accessibility issues, or any other problems you encounter with this script.
This package contains the following files:
/poll/readme.txt(instructions and extra information)poll.php(primary script include)common_functions.php(functions shared by the admin and public scripts)jdp_functions.php(functions required by thepoll.phpinclude)mysql_connect.php(MySQL connection script)table2chart.js(Javascript to generate a Google Chart from the table of results, by Christian Heilmann)default_styles.css(default styling for the poll output)/admin/admin_functions.php(functions required for the administrative script)index.php(main administrative scripts)admin_styles.css(styling for the administrative scripts
Features of this poll script:
- Controls ballot stuffing by recording votes in a cookie. Replaces previous versions attempt to control multiple votes through recorded IP addresses.
- Supports polls with any number of questions and any number of option responses. Questions do not have to have the same number of responses.
- Accessible results and forms
- Valid XHTML strict 1.0 code
- Reasonable number of handles for CSS modifications
- Chart graphics are generated externally via the Google Chart API, minimizing the support requirements and processing demands on your server.
- Web management interface for polls. Allows generation of new polls and limited editing of existing polls. Will be expanded in time - Subscribe to my blog by RSS or by email for updates.
Find this useful? Encourage it! Make a donation.
Log of Script Changes
- 2008-04-16 — Modified
admin/index.php,admin/admin_functions.phpandindex.php. Corrected one minor variable which defined an inappropriate default value and fixed a security hole in the administrative end. Note: you should still remove/adminwhen you are not using it. Thanks to Mike Cherim and Thomas Anderson. - 2008-06-09 — Modified
admin/index.phpand/readme.txt. Corrected an error in sample output code and an error with a required field which was labeled as optional. Added information concerning mysql connections to the read me file. Anonymous Correction - 2008-10-30 — Modified a number of minor errors in
jdp_functions.php,poll.php,common_functions.php, andadmin/index.php. Mostly, these are bug fixes relating to support in Windows environments; one fix (injdp_functions.phpis for a function which was missing. (Whoops!)
See also:
- More about Boolean Fulltext queries in MySQL
- Search Engine with Boolean Fulltext Queries
- Processing Forms with PHP, A Beginner's Guide
For Further Reading:
If you want better information on MySQL's extensive uses with PHP, you may want to look into broad-coverage texts such as PHP and MySQL Web Development, by Luke Welling and Laura Thompson or PHP and MySQL for Dynamic Web Sites, by Larry Ullman. The Welling and Thompson book gives you a whopping 984 page comprehensive manual to PHP and MySQL web development where Ullman's text is a valuable introduction to the topic.
This work is licensed under a Creative Commons license with some rights reserved.
