Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Preventing Double submit on refresh/back


Matthew1980 - 10:36 am on May 13, 2010 (gmt 0)


Hi there Marked,

HTML code:-

<form method="POST" action="">
<input type="submit" value="Submit" name="submit"/>
</form>

PHP code:-

<?php
if(isset($_POST['submit']) && ($_POST['submit'] == "Submit"))
{
execute some code when the form is submitted
}

This is what I use, and I haven't had a 'double submit' yet. Ie check the value of the key, then process.

Changing $_POST to $_GET is only good if you create the vars and pass them in the URL, $_POST is from the form submitted data.

I suppose there is some fancy js out there that would disable the submit button when it is actioned, but I have never tried this method.

Hope this helps..

Cheers,
MRb


Thread source:: http://www.webmasterworld.com/php/4131929.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com