Polling script
Date: 02/11/05
(PHP Development) Keywords: php, web
Hello everyone.. don't really post too much in here, but I thought i'd get some input from everyone. For the past few days, I was interested in how GD works, so I decided to write a script that would put it to use. I decided to write a poll for one of my clients, and it seems to be working pretty well. Heres a quick idea of how it works.
- Poll module is loaded at the beginning of the script (before output) (will go into modules more in a minute)
-- Just sets an array containing the very basic config of the poll (which db tables to use and whatnot) and also contains cookie information.
- $cfg_poll['poll'] is set to tell which poll to load.
- submodule 'poll_load' is loaded.
-- DB is queried getting a bit of info on the pull (question being asked, size of poll graph, etc.
-- DB is also queried to see if an IP matching the remote_addr exists in the answer table
-- Last but not least, check if cookie exists for answering the poll
If the last two things are matched, load poll_results, which just gets the answers from a db, and shows a graphical display of the poll.
If those two aren't matched, display a form for submitting your answer to the poll.
Anyways, if anyone has some input on this, that'd be great. I'll throw up an example when I get some real webspace. As you can see, this whole thing is done from a DB, and is fully customizable.
Also, the whole 'module' is because this script runs off of mod_core.php, a script I wrote for making large projects easier. In short, modules are made, sub-modules can be loaded, contains debug info, etc.... Doesn't hurt too much on CPU usage either.
Thanks,
~ Fanaticus
Source: http://www.livejournal.com/community/php_dev/52493.html