Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am making a website which will allow a user to vote for one of the two images present on the page.
My requirements are:
1) Only 1 user should be able to vote once
2) After voting, results should appear on the page (above the image voted)

Would really appreciate help!

What I have tried:

Created a normal voting button with counter
Posted
Updated 29-Oct-22 5:51am

1 solution

Unless you never close the page and store the voting tally on the page, you really cannot do what you want to do.

JavaScript is a client-side language. You need to store the data (on the server) and that requires a server side language (I prefer php). You can then store the vote tally on the server in SQL type database (or even in a server-side flat file).

The one vote per person: you need to determine some method of uniquely identifying each user, and then noting (again, server side) if they've voted or not. You can keep separate tallies of who voted and the votes, or, if privacy is of no concern, keep them together (allowing changes, possibly).

So - here's a place to start: PHP Tutorial[^]

Since flat files are a possibility, although inefficient, you can get away without SQL.

Need support on your server for PHP, a database, etc., ? Vertigo[^] is very good and free.



 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900