sonal Posted December 3, 2011 Share Posted December 3, 2011 I'm trying to make a poll script, where users can select an answer for a particular question. How to avoid multiple answers from the same user? I tried to set a cookie in the questions.php page which displays questions and answers. Then trying to access that cookie in submitanswer.php page, to run it if(!isset($_COOKIE['poll']) { // update the answer counting. } else { echo "only one answer" }. But this is not working. The cookie is always set as it is coming from the previous page, in this scenario. How can a cookie be helpful here? Or is there anything else I need to know/do? thanks Link to comment Share on other sites More sharing options...
Dark Prince Posted December 7, 2011 Share Posted December 7, 2011 if you have it setup where the person has to be logged in then create a table in mysql that logs there userid and the poll id then if it exists give the error that they already answered the poll if not you can log there ip address instead of a userid, when using cookies they can easily delete it and poll again atleat with a database they can't 3 Link to comment Share on other sites More sharing options...
sonal Posted December 8, 2011 Author Share Posted December 8, 2011 thanks. I'm going to try ip address check. I'm keeping poll open, and don't want users to register or log in for this poll. I'm trying to learn and practice these things. Link to comment Share on other sites More sharing options...
Antonio Conte Posted December 8, 2011 Share Posted December 8, 2011 Have you checked out Facebook-login or something similar? Using Dark Prince's suggestion with this should be possible. IP-adresses do change, even if that's not such a big problem as with cookies. 1 Link to comment Share on other sites More sharing options...
sonal Posted December 9, 2011 Author Share Posted December 9, 2011 no, . Is it something that "Login via Facebook" on other sites? (I know, I sound so dumb.. Link to comment Share on other sites More sharing options...
Antonio Conte Posted December 10, 2011 Share Posted December 10, 2011 That's right. I'm sure Facebook har good documentation for this. Google it. Link to comment Share on other sites More sharing options...
Recommended Posts