Home arrow PHP arrow Page 2 - Creating a Fraud-proof Voting System

One Person, Multiple Addresses, Still One Vote - PHP

Setting up polls or voting systems is a great way to get users more involved in your website, and keep them coming back for more. But with fraud hanging over the professional political elections, how do you keep your visitors from screaming for a recount--or worse, stuffing the ballot box? Ian Felton describes a simple system for setting up an online poll and preventing abuses.

TABLE OF CONTENTS:
  1. Creating a Fraud-proof Voting System
  2. One Person, Multiple Addresses, Still One Vote
  3. One Vote.php, Two States
  4. Trust but Verify
By: Ian Felton
Rating: starstarstarstarstar / 143
December 21, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Sending the email is only the first step for fraud prevention because some people have a thousand email addresses. Someone could (and would) vote for the same song using all of their email addresses and skew the results in that way. Because of situations like that, the system also needs to verify that fans aren稚 using multiple email addresses. The verification email also needs some sort of key so that the verification script cannot be easily hacked.

Two scripts comprise the bulk of the system. One script, vote.php, casts the vote and sends the verification email. Another script, verify.php sets the vote as valid after Dick clicks the link in his inbox. A table in the database will need to be created to store votes.

First, we値l setup the table in the database to store the votes that are cast. We need a basic primary key called ID. We値l store the email address of the voter. We値l timestamp the vote. We need a column that shows whether the vote has been verified. It will be a Boolean flag. We値l store the ID of the band receiving the vote. We値l store the song name and finally the IP address of the voter.

CREATE TABLE `votes` (
`ID` int(10) unsigned NOT NULL auto_increment,
`email` varchar(255) NOT NULL default '0',
`time` timestamp(14) NOT NULL,
`pending` tinyint(1) unsigned NOT NULL default '0',
`bandID` int(10) unsigned NOT NULL default '0',
`song` varchar(255) default NULL,
`IP` varchar(15) NOT NULL default '0',
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`),
KEY `ID_2` (`ID`)
) TYPE=MyISAM AUTO_INCREMENT=0;



 
 
>>> More PHP Articles          >>> More By Ian Felton
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap

Dev Shed Tutorial Topics: