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 9 of 9
  1. #1
    New Coder
    Join Date
    Dec 2008
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Allowing one person to vote at a time

    Hi All

    I'm pretty new to php and the forums, but I have a dying question and can't seem to find an answer that works for me!

    Bascially I am setting up a voting poll and want to know if there is anyway to allow only 1 person to vote, to avoid people voting load of times.
    Any ideas?

    Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Find a pre-made script ...

    like this: http://www.hscripts.com/scripts/php/starrating.php

    or like this: http://www.hscripts.com/scripts/php/...-no-rating.php

    Customize it for your own use (if needed).
    Not having to re-invent a script (use an existing one) is probably the fastest way to go.

  • Users who have thanked mlseim for this post:

    nico_icecold (12-09-2008)

  • #3
    New Coder
    Join Date
    Dec 2008
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Cool..cheers!

    Will give that a try!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    No you can't, not for anonymous users anyway.
    The only way to actually control this is to create a user system to track people. There is no reliable way using PHP to identify a specific user.

    That being said, there are a few ways to kinda help. Cookies, ip addresses, etc. For functionality, just use one of the systems from mlseim's links.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    If you have a login system on your website then it is easy.

    When a new poll is created, when it inserts into the database, also update the users poll field to 0. Then when they vote it changes to 1. Block voting if users poll is equal to 1.

    If you have multiple polls going, you can put like poll1, poll2, poll3 in your users table, and update it by poll id.

  • #6
    New Coder
    Join Date
    Dec 2008
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Cheers guys. unfortunatley I dont have a login system, but I have heard of a way to do it using the cokies, but the only problem I might face is that people may clear their cookie files. I think IP is the one here! I'm gonn ahave a scout around and see what I can find!!!

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Ok then yes IP will be the way to go. If they have a router they can get a new IP in minutes.

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Voting polls are like web page hit counters.

    They can show any number, they are meaningless, and nobody really cares about them.
    Questions misread, answers skewed ... and reliant on demographics.

  • #9
    New Coder
    Join Date
    Dec 2008
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Okay..sorted this now..decided to use a cookie..alllows only one person per pc to vote..thats really the only way i could narrow it down!


  •  

    Tags for this Thread

    Posting Permissions

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