Implementing a web-poll, just how easy?
Tuesday, March 30th, 2004So I’m pondering the implementation of a quick poll. Say I wanted to have people vote for their favourite Struts book. Not too hard. I’ve done such things in the past with a few lines of php and a mysql table.
I hit a problem with my pergamum site though. It’s all static. So I wonder, what would be the easiest possible way to implement a poll, hopefully keeping it utterly static.
Here’s my [just in my head] solution:
The poll merely links to a relatively empty page, which redirects to the results page. The results page mentions that the poll is updated every 5 minutes, so the voter’s vote won’t be shown yet [an unfortunate downside]. Additionally, the server has a simple cron-job which greps the web-logs for the urls and ips, weeds out any duplicates and generates the results page, every 5 minutes let’s say.
All very static as far as the server is concerned, and very, very basic. To make it easier, I could possibly configure Apache to log those particular special urls [say they all end in .vote] to a special log, and the cron could check to see if the special log is newer than the results page. Then it could possibly be run more aggressively.
Bizarre…yet I like the cut of its jib. Now to wait for the itch to strike to implement such a thing. Maybe I could make it a more global thing, not a poll but a category-vote, which would end up with a best-of-category series of books.
