Hey quick question...
so we're putting together a discussion board that has a 'poll-type' capability.
Basically, if the users are already authenticated, what is the easiest way of making sure they can't vote twice on a poll???
Thanks as always,
Andrew
Ensuring a user Can't vote twice
Moderator: General Moderators
Re: Ensuring a user Can't vote twice
create a DB table:
user_id: poll_id
on voting - create the appropriate record.
So, if a record exists then user has already voted.
user_id: poll_id
on voting - create the appropriate record.
So, if a record exists then user has already voted.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Ensuring a user Can't vote twice
Thanks!
I guess my question really is... how do I check the table to make sure that the user hasn't voted?
Do I have to run two queries or can I do it all in one... (sorry if this is turning into a DB question)
I guess my question really is... how do I check the table to make sure that the user hasn't voted?
Do I have to run two queries or can I do it all in one... (sorry if this is turning into a DB question)
Re: Ensuring a user Can't vote twice
Which 2 actions do you want to do with 1 query? I wouldn't advise trying to authenticate and check the vote for a user in 1 query.
In 2 queries it's pretty straightforward. 1 query to authenticate the user, 1 query to see if that user id has already provided an answer for the poll.
In 2 queries it's pretty straightforward. 1 query to authenticate the user, 1 query to see if that user id has already provided an answer for the poll.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.