how to allow only one vote for a rating system

孤街醉人 提交于 2019-12-01 12:20:42

问题


guys i have made a jquery and css based star rating system. now i cant really think of way as how to save the user vote to database. and most importantly how to limit one user only to one vote.

since the number of visitors in the site is huge, i cant afford saving each user's ip to the database. and moreover i don't think it works good because even my ip address itself is dynamic. every time i disconnect and reconnect my internet my ip changes and i am able to vote again. so i don't think this will work.

this is what i have thought about saving the votes to the database: ill just save the number of votes a page has received and ill save the total rating of the page.

and ill divide the rating points with number of votes. so it will give me the average rating. right?

but i can think of no way to limit one user to one vote. please help.


回答1:


There seems to be no practical way to strictly enforce one vote per person on the web.

On computer networks, we often use surrogates for people. Some of them are

  • network or application login,
  • email address,
  • IP address,
  • cookies,

and so on. But all of these have problems when it comes to one vote per person.

  • For web logins, a person can usually make multiple accounts. (Especially if they're free.)
  • Email accounts are free, and many (most?) people now have multiple email accounts.
  • IP addresses might work, but only on intranets (implemented with one IP address per computer) with unshared computers (company policy of one person per computer).
  • Cookies have the same problems as web logins. (And they can be deleted by the user.)

If a vote is really valuable, some people will go to a lot of trouble to vote twice. But most votes aren't very valuable.




回答2:


Look into structuring your database with indexes. I created a user favorite system that only allows one row to be inserted per user/favorite combination. For example: a user chooses a favorite, the values stored in the database are User ID and Favorite ID. If the user tries to select it again, the database won't insert the row as it is an exact duplicate.



来源:https://stackoverflow.com/questions/12810793/how-to-allow-only-one-vote-for-a-rating-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!