It's a fact: Web poll results are not an accurate reflection of the population at large. First, many people choose not to participate in polls, and there's nothing you can do to change that. Second, some people will try to skew the results by casting multiple votes. There are ways to limit users to one vote, but determined users can get around all of them.
You can set a cookie whenever a user casts a vote, but there are two problems with this: 1) Some users disable cookies, and 2) Some users regularly clear their cookies. So some people will be unable to vote, while others will be able to vote more than once after clearing their cookies.
You could also log the IP address of each visitor, and allow only one vote from each address. Once again, there are two problems: 1) Some users share a machine with other users, or have access only through public machines, and 2) Some users have access through multiple IPs, for example, at home and at work. Users with dialup connections may be assigned a different IP address each time they connect. Once again, some users will not be able to participate, and others will still be able to vote more than once.
You might force users to register their email address and log in before voting. Then you could add another table to the database to track which polls each user has voted. Again, there are two problems: 1) Some users will not want to bother with setting up an account just to vote in a poll or will not want to give out their email address, and 2) Some users will use multiple email addresses to beat the system and vote more than once.
There's no sure way to keep a determined user from skewing the poll results. So take polls for what they are worth and don't put too much stock in their results. Done right, a poll can be an easy way to let visitors interact with your site, and it's usually more fun than getting bitten by a ferret.
About the Author
Bruce Alderman is a Systems Specialist by day and a freelance writer by night, yet he still manages to find time for hobbies like PHP programming. He lives in Wichita, Kansas. He has never been bitten by a ferret, but it's on his list of things to do.
Thanks to Lawrence Pires for pointing out a couple of errors. They have been fixed. -Ed
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.