Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Question is there a way to restrict voting to once a day?

    I have a poll and I want to allow user to vote only once a day.
    I save the data in a table named "polls_vote" and I have 2 columns there:
    pollid
    ipAddress

    and I use this mysql query to check if there is already one ip in the table:
    SELECT * FROM polls_vote WHERE ipAddress = '$ip' AND pollid = '$pollId'

    if you need any more info ask.
    thanks.
    Last edited by shedokan; 01-03-2008 at 04:30 PM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I'm at a workplace that has 20 computers.
    Nothing would keep me from voting 20 times ... each one has a unique IP address.

    But I guess if you saved a date value of when I voted along with the vote,
    you could ignore any more votes from the same IP (if the date was the same).
    It would cut down on multiple votes.

    I wouldn't mention anything ... just ignore any extra votes without any indication.

    If someone knows you are checking their IP, they would be more tempted to abuse it.

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,045
    Thanks
    2
    Thanked 316 Times in 308 Posts
    The reverse it true too, most of the computers behind a router will have the same IP address. Do you want to limit a company that might have 10, 100, or 1000 people to just one vote?

    Using an IP address for anything other than just activity logging and reporting purposes is unreliable, because an IP address does not identify any single visitor.

    IP addresses can be different for the same visitor on different visits (either deliberately if he want to vote more than once or accidentally if he is using a dial up connection and got a new IP address just because he connected again) and several visitors can have the same IP address (either because they are in a network where that IP address is shared or because they got assigned the IP address on one visit that someone else previously had on their visit.)

    If you describe what type of voting is taking place, someone can provide a more reliable method.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    There's no good way to do this.

    If you use cookies, people can just clear their cookies.

    The two significant issues with using IP addresses have already been mentioned.

    If you make people register with an email, people aren't going to want to give out their email address and go through the whole process just for a little poll. Plus they can register several times with different free email addresses.

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I agree with all of the posts ...

    Online Polls are not reliable and should just be used for "fun".

    Let us know what the purpose is ... how important the poll really is.

    Don't think that a "leave a comment" guest book will be any better.
    You'll get comments that are somewhat questionable and probably vulgar.

    The internet is great for posting your thoughts and ideas, but without
    moderation and censorship, accepting ideas from others is usually a bad idea.

    ====

    I tried talking a local church into eliminating their "open" online guestbook.
    They insisted on leaving the guestbook online.
    .
    .
    ... I see it's not online anymore


    .

  • #6
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Exclamation

    It's for a fan website about neopets.

    the voting is anonymous so any user can press vote and the vote is added to the database.
    and I'm using ajax so the page doesn't needs reloading.

    Do you want to limit a company that might have 10, 100, or 1000 people to just one vote?
    people from a company don't need to vote but to work.

  • #7
    Regular Coder
    Join Date
    Mar 2005
    Posts
    156
    Thanks
    8
    Thanked 1 Time in 1 Post
    Quote Originally Posted by mlseim View Post
    I'm at a workplace that has 20 computers.
    Nothing would keep me from voting 20 times ... each one has a unique IP address.
    This is not altogether true as those 20 computers have separate Internal IP addresses, but their external (which is all that this script would see) is the same.

    So it is still not completely legit because only 1 of those 20 will be able to vote per day, but if you are not aiming at work as per your last post...
    people from a company don't need to vote but to work.
    then writing something to check by IP should work for what you are aiming at.

  • #8
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Exclamation

    but then users can only vote once per a poll and not once per a day.
    Last edited by shedokan; 01-04-2008 at 06:44 AM.

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,045
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Dormitory Internet connections at a University would also share single/few IP addresses. Likewise, hot spots, Internet Cafés, and people that go to their library to connect would have many people behind one IP address.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    ok, so what do you think I should do?
    Last edited by shedokan; 01-04-2008 at 06:52 AM.

  • #11
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    For Neopets ... go ahead and do it.

    It's for fun and the demographics is kids.

    To keep a child from hitting the vote button over
    and over again, just set a session variable.

    Alternatively, you could use a cookie with a 12 or 24 hour expiration.

    I don't think kids will keep opening and closing
    their browser to vote.

  • #12
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    ok, thanks for the advice.
    I will go with cooies because sessions last only 5 minutes.

  • #13
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    sessions only last 5 minutes?

    That must be a hosting PHP setting.
    Sessions on my site last as long as the browser is open.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •