/    Sign up×
Community /Pin to ProfileBookmark

Limit voter to only 1 vote on OnlinePolling system using cookies

Limit voter to 1 vote only on OnlinePoll using cookies

I’ve created an online polling system, using a simple radio button Form with a get method of “Post” The voter simply makes their selection, then clicks on SUBMIT.

My problem is some visitors click on the BACK button and make multiple votes. ? I’ve been able to track the users IP Address,Remote Host name and time/date stamp via CGI script. So I can tell pretty much who are the flying voters. So I just delete the excess votes, but that can be a hassle if they vote abt 50 times. Is there a way to use cookies to store the voters selection and prevent them from using my Poll.html to vote over and over again?

I took a crash course in CGI so I’m fairly new at this. Anyway, my polling system consists of 4 files:

[COLOR=royalblue][B]1) Poll.html[/B] (the actual form)[/COLOR]

[COLOR=red][B]2) Poll.cgi[/B]

[list]

  • [*]

    When a user clicks on the SUBMIT button from Poll.html, this CGI is then called.

    If user made a selection then this CGI prints out a message, “Thank you for your vote,you voted for ‘John Doe’ for Instructor of the year!” Click here to view current Poll results. The selection is then appended to a text file called votes.txt via the
    [/COLOR]

    [CODE]
    open (FILE, “>> votes.txt”);
    print FILE, “$Instructorn”;
    [/CODE]

    [COLOR=red]
    If user didn’t make a selection, an error
    message is displayed asking user to
    return to Poll.html by clicking on
    BACK button and make a vote.
    [/COLOR]


  • [/list]

    [COLOR=purple][B]3) Poll_results.cgi[/B]

    [list]

  • [*]

    This tallies all the votes for each nominee.

    This is not actual code… I actually used an array for each and used a foreach loop in my script, this example is for the purpose of demonstrating how I computed the barwidth.

    [CODE]
    ex: $Totalvotes = 200
    $JDvotes = 100
    $Janevotes= 22
    $BDvotes = 38
    $BSvotes = 40

    $JDbarwidth= $JDvotes/$Totalvotes
    [/CODE]

    [COLOR=purple]
    and create a bar graph using the number
    of votes for each one as the table width.
    [/COLOR]


  • [/list]
    [CODE]
    ex:
    <table>
    <tr>
    <td width = $JDbarwidth bgcolor=Blue>
    |
    </td>
    <td>
    $JDbarwidth%
    </td>
    </tr>

    ex: John Doe ||||||||||| 50%
    Jane Doe ||| 11%
    Ben Dover |||| 19%
    Bart Simpson ||||| 20%
    [/CODE]

    [url=http://staff.washington.edu/rcarpizo/test/Nominees_read.cgi]Click here to see the actual result[/url]
    [/COLOR]
    [COLOR=royalblue][B]4) voters.txt[/B]

    [list]

  • [*]

    Consist of data saved via CGI’s append to file.

    Each line appended/saved is the Voters selection, IP address of voter,date/time stamp per line. (n)
    [/COLOR]


  • [/list]

    Is there a way to use cookies to store the voters selection and prevent them from using my Poll.html to vote over and over again?

    Thanks in advance for any help you can provide. ?

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @just4kix spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...