tinfoil Posted February 16, 2014 Share Posted February 16, 2014 I'm trying to make a javascript voting system and I got a few questions about the fundamentals. What I plan to do so far is to make objects with a "votes" key along with a key for name, submission date, etc. But here are some of my concerns: 1. I want the votes to be casted from multiple pages on the site. If I just make the objects on the homepage, would the objects be accessible from other pages? 2. I want to limit how much each users can vote daily, but only by their IP address. Is there a javascript function to detect IP addresses? Are there any good resources on this topic? I still have a lot to learn. Thank you Link to comment Share on other sites More sharing options...
davej Posted February 16, 2014 Share Posted February 16, 2014 (edited) This introduces a number of questions such as -- where are you going to store the votes? You would need a server-side language such as Php. You could then post a voting form to Php. Php would have to store the vote in a file on the server or in a database. Php can detect the users IP address. http://www.w3schools.com/php/php_forms.asp http://www.w3schools.com/php/php_superglobals.asp Edited February 16, 2014 by davej 1 Link to comment Share on other sites More sharing options...
tinfoil Posted February 16, 2014 Author Share Posted February 16, 2014 This introduces a number of questions such as -- where are you going to store the votes? You would need a server-side language such as Php. You could then post a voting form to Php. Php would have to store the vote in a file on the server or in a database. Php can detect the users IP address. http://www.w3schools.com/php/php_forms.asp http://www.w3schools.com/php/php_superglobals.asp Alrighty. Looks like im gonna have to read up on that. Would the javascript objects still come into play? Like for the votes key would I have to call up the votes from wherever PHP stored it? Link to comment Share on other sites More sharing options...
davej Posted February 16, 2014 Share Posted February 16, 2014 (edited) Probably the simplest approach would be to have one .php page that receives the posted forms and stores the votes and one .php page that displays the voting totals. Edited February 16, 2014 by davej Link to comment Share on other sites More sharing options...
tinfoil Posted February 17, 2014 Author Share Posted February 17, 2014 Probably the simplest approach would be to have one .php page that receives the posted forms and stores the votes and one .php page that displays the voting totals. For the site im planning to make voting is kind of the main purpose of it, so I need to spend some time on making one that does more than that. I dont plan on adding any other complex (just some pictures, graphs, and videos for now) so I can afford put a lot of focus into that voting system. I appreciate the help though you helped me on all my threads so far Link to comment Share on other sites More sharing options...
justsomeguy Posted February 17, 2014 Share Posted February 17, 2014 If you want a Javascript component then you can write a set of functions or objects that will use ajax to submit the votes or read the totals and display the voting form. Using ajax would let people vote without the page refreshing. When the ajax request comes back from PHP then Javascript could remove the form and show the current results, or something similar. Anything regarding security would need to be done with PHP rather than Javascript. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now