Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-26-2012, 12:19 PM   PM User | #1
aaron4osu
New Coder

 
Join Date: Oct 2010
Posts: 66
Thanks: 29
Thanked 0 Times in 0 Posts
aaron4osu is an unknown quantity at this point
Limiting votes by users without an account

I'm working on a site that allows users to vote on different items. Right now I have it so after they vote the buttons are disabled until the page refreshes. I want to come up with a solution so I can keep users from voting more than once. Currently, I'm storing votes in a mysql database, but I'm not storing who voted.

I have 3 different types of users.
1) members logged in
2)members not logged in
3)site visitors with no user account

I'm trying to think of the best ways to handle each type.

I know for my logged in users I can use their user_id and check if they have voted before for that specific element.

But how should I handle the other two (2 & 3). Here is what I'm thinking...

a) Should I use set a cookie for each of their votes. Then, loop through all of their vote cookies each time they vote before adding the vote to the database? There could be hundreds of votes. If they have cookie turned off this would not work.

b)maybe grab their ipaddress somehow and store that in the database. Then query and loop through all votes looking for a duplicate ipaddress/item combo?

c)something more efficient?
aaron4osu is offline   Reply With Quote
Old 06-26-2012, 07:28 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 950
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
Option a is easiest to implement, and easiest to get around. Option b is useless unless you can guarantee that all visitors aren't on ISPs that force IP address changes.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Users who have thanked WolfShade for this post:
aaron4osu (07-02-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:58 AM.


Advertisement
Log in to turn off these ads.