CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   One Vote per IP (http://www.codingforums.com/showthread.php?t=273900)

Hydrian 09-23-2012 10:04 AM

One Vote per IP
 
I have a application where users can vote for submission, and i want to make sure users dont spam it, how can i make this one vote per IP?

Code:

<script type="text/javascript">
 var clicks2 = 0;
 
 function linkClick2()
 {       
 document.getElementById('clicked2').value = ++clicks2;
 }
 document.write('<a href="#" onclick="linkClick2()" class="vote_link">Vote for this Submission</a>');
 </script>


Philip M 09-23-2012 10:41 AM

You cannot do that with Javascript. You must use server-side coding.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Hydrian 09-23-2012 10:45 AM

Quote:

Originally Posted by Philip M (Post 1272513)
You cannot do that with Javascript. You must use server-side coding.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

how would i go about doing that tho?

Philip M 09-23-2012 10:52 AM

Quote:

Originally Posted by Hydrian (Post 1272515)
how would i go about doing that tho?

Ask in the PHP forum. You will need to keep a database of IP addresses that have voted.

Old Pedant 09-23-2012 10:35 PM

Or ASP forum or Java forum...depending on what kind of server-side language you want to use.

felgall 09-23-2012 10:41 PM

It isn't exactly going to be fair though - where 1000 people are sharing the same IP only the first of them to vote will have their vote accepted while someone else whose IP address changes regularly will still be able to cast multiple votes.

Of course that may not matter depending on the requirements.

Philip M 09-24-2012 07:46 AM

Have a look at

http://www.technabled.com/2011/02/pu...wn-voting.html

http://www.freepolls.com/

rnd me 09-24-2012 10:42 AM

use the ip as the primary key of a 2-col poll table.

the vote is an integer 0-5 or whatever.

Code:

IP        VOTE
1.1.1.1  4
1.2.1.1  2
1.2.1.1  2
4.2.1.1  0
1.2.9.1  3

i use zero here to 'cancel' a vote for a given ip. looks like #2 is winning...

in this way, someone can update their vote, but they can't vote more times than you can reasonably screen against without sign-in.

yes, they can vote at the coffee shop, on their phone, and at work, but they can't sit there and vote 500 times in a row...

Old Pedant 09-24-2012 11:37 PM

But Felgall's point needs to be considered as well: Many people use large-scale ISPs or are on machines behind a company firewall. In such cases, you can have hundreds or even thousands of users (e.g., Microsoft has only a handful of outward facing IP addresses for all its thousands of emploeyees) with the same IP address. So if one person using that ISP or from that company votes, nobody else will be able to.

Now, maybe you don't care about these people, and that's really fine. Just be aware that the problem exists.


All times are GMT +1. The time now is 05:59 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.