This is a discussion on Voting idea within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi I am trying to make voting script I ,BUT for sorry I cant add new question and any number ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Message-ID: <1139311257.195325.268460@z14g2000cwz.googlegroups .com> from
Beshoo contained the following: >Hi I am trying to make voting script I ,BUT for sorry I cant add new >question and any number of choices !!!! >pleeeeeeez if you have any way out teel me >thaaaaaaanx in advance To do that you need a database with two tables. I used this: -- -- Table structure for table `poll` -- CREATE TABLE IF NOT EXISTS `poll` ( `poll_id` int(11) NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `question` varchar(255) NOT NULL default '', `expires` date NOT NULL default '0000-00-00', PRIMARY KEY (`poll_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=48 ; -- -------------------------------------------------------- -- -- Table structure for table `poll_answers` -- CREATE TABLE IF NOT EXISTS `poll_answers` ( `answer_id` int(11) NOT NULL auto_increment, `answer` varchar(255) NOT NULL default '', `poll_id` int(11) NOT NULL default '0', `votes` int(11) NOT NULL default '0', PRIMARY KEY (`answer_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=149 ; -- Geoff Berrow 0110001001101100010000000110 001101101011011001000110111101100111001011 100110001101101111001011100111010101101011 |
|
|||
|
Geoff got you started in the right direction (assuming you are using mysql).
There are other considerations for a voting script as well. The least of which is making sure one person can't sit and vote a whole bunch of times. To stop this major problem, I like to make it so only registered and logged in users can vote. You may need a third table to keep track of user_id, poll_id, answer_id, and time(). Then a quick: "select * from poll_answer_history where poll_id = blah and user_id = blah" will tell you if your current user has already answered. "Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message news:u8diu1lcd2gb8tq4jil3ui5dumiql6r7os@4ax.com... > Message-ID: <1139311257.195325.268460@z14g2000cwz.googlegroups .com> from > Beshoo contained the following: > > >Hi I am trying to make voting script I ,BUT for sorry I cant add new > >question and any number of choices !!!! > >pleeeeeeez if you have any way out teel me > >thaaaaaaanx in advance > > To do that you need a database with two tables. I used this: > > > -- > -- Table structure for table `poll` > -- > > CREATE TABLE IF NOT EXISTS `poll` ( > `poll_id` int(11) NOT NULL auto_increment, > `title` varchar(255) NOT NULL default '', > `question` varchar(255) NOT NULL default '', > `expires` date NOT NULL default '0000-00-00', > PRIMARY KEY (`poll_id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=48 ; > > -- -------------------------------------------------------- > > -- > -- Table structure for table `poll_answers` > -- > > CREATE TABLE IF NOT EXISTS `poll_answers` ( > `answer_id` int(11) NOT NULL auto_increment, > `answer` varchar(255) NOT NULL default '', > `poll_id` int(11) NOT NULL default '0', > `votes` int(11) NOT NULL default '0', > PRIMARY KEY (`answer_id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=149 ; > > > -- > Geoff Berrow 0110001001101100010000000110 > 001101101011011001000110111101100111001011 > 100110001101101111001011100111010101101011 |
|
|||
|
That may not work, cuz IP addresses may or may not persist between
sessions - it depends on your network. Cookies might work, or might not - if some users have access to several machines. The email address technique noted above is probably best, but also unreliable and inconvenient. AS "Beshoo" <basheermoro@gmail.com> wrote in message news:1139394349.818696.162130@f14g2000cwb.googlegr oups.com... > Oh !! thnk u very much i have done it. > but,I have another idea to prevent the user fro voting more than 1 time > by get the his IP !!! > > thanx !!! > |