I just came back to ask this quesiton. It's been a while since I was on here, but over time I made myself a poll. I just wanted to know, on my poll, I use one page to show the form, add the vote, and show the results. My question is, why I vote, and it stays on the same page and shows the results, if I press refresh, it adds the same vote as many times as I press refresh. How can I stop that from happening? Thanks a lot, I really appreciate it!!

When you've sent form data, the resulting page is generated using the form data. So if you're refreshing the page, you keep getting the page with the form data being submitted. The problem is every time this happens, your database logs it as an entry.

You've got two options, log according to session ID (once per session) or using their IP address, OR log to another page which transport you back to the results page. So refreshing will redisplay the results page without sending the form data (because that was on a previous page)

Yes, on the page where I insert their vote, I also insert their IP with the pollid, so that it will display the votes from now on. Well, I'm hoping to change my poll, but right now, somehow I made it so that when I do do it on 1 page, when you vote on 1 page, click refresh, it shows it once. I was just wondering, does the "mysql_close()" do anything? I put that down, and it didn't insert each refresh. Does that also do it? Thanks!

mysql_close() closes the connection wherever it occurs within a script. But PHP scripts are not programs. They are accessed and run only when that page is requested. For refreshes or other pages, they are run again!

What you should be doing is using the session ID (since there's a very small chance that will be duplicated) alongside the date and IP (just in case someone closes their browser and comes back to mess up your votes). Then check if the session ID exists, if not, check if that IP posted a vote in the last X minutes, if not, then you can enter the vote!

Thanks, I will try that. I really appreciate it. But this is the weird thing. If you have time, go to my site: http://www.coopercentral.org and on the homepage, there will be a poll. Just vote on an option. Then right when it shows the results, press refresh, it doesn't add the vote. I KNOW that I'm not using any Session ID's. I am logging IP's so it will show the results, but I don't know. Thanks!