CodeIgniter Forums
How to disable refresh option in my php page? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: How to disable refresh option in my php page? (/thread-32932.html)



How to disable refresh option in my php page? - El Forum - 08-10-2010

[eluser]Unknown[/eluser]
Hi,I have problem with entering data into a sql database from php webpage. However I'm doing everything in one page. Is there any way to stop the resending of the query on refresh or do I have to use more than one webpage to get around this. I'm very new at this and am a little intimidated by multiple webpages.

Thanks in advance.


How to disable refresh option in my php page? - El Forum - 08-10-2010

[eluser]mddd[/eluser]
The simple way is to use a token which can be used only once.
When you generate the page, you put in a hidden form field containing some random number. The number is submitted along with the rest of the form. You store that number somewhere. If you get another request you check to see if the number is not the same as any of the ones you recently received.
That way you prevent double entry of the data.