arianhojat Posted April 27, 2007 Share Posted April 27, 2007 I saw this article which helps out: http://www.bigtrapeze.com/double_post/postblock.php I get how it posts a random hidden form # on each page, and if its the same as the last submitted form(kept track of via session variable), it tells you its a double post (or you can put some code in to redirect to another page). I was also wondering how to stop pressing the submit button twice. i dont think this postBlock class catches that. My only guess is to disable the submit button, onsubmit. Link to comment https://forums.phpfreaks.com/topic/48983-solved-preventing-double-posts-on-a-form/ Share on other sites More sharing options...
per1os Posted April 27, 2007 Share Posted April 27, 2007 You want Javascript. Something like <script type="text/javascript"> function disableButton(button) { button.enable = false; button.value = "Processing..."; } </script> <input type="submit" value="Submit!" onClick="disableButton(this);" /> I am not sure if the code is correct or will work, but yea. http://javascript.internet.com would be a great resource for find working code. Link to comment https://forums.phpfreaks.com/topic/48983-solved-preventing-double-posts-on-a-form/#findComment-239963 Share on other sites More sharing options...
Psycho Posted April 27, 2007 Share Posted April 27, 2007 My only guess is to disable the submit button, onsubmit. That's what I typically do. Of course you can never count on the fact that all users will have javascript enabled, but most do. So, the risk is much smaller. For those who don't you have several options: 1. Do not allow them to submit/use the form if javascript is not enabled (e.g. do not have a true submit button, use javascript to submit) 2. Create some back-end functionality as you stated to identify duplicates 3. Do nothing. This is a valid solution depending upon the situation. If it is a form to create a user account there should be validation to prevent a duplicate from being created. however, if it is an ordering page you don't want to allow the user to place two orders. Link to comment https://forums.phpfreaks.com/topic/48983-solved-preventing-double-posts-on-a-form/#findComment-239968 Share on other sites More sharing options...
arianhojat Posted April 27, 2007 Author Share Posted April 27, 2007 cool thanx. ill just disable the button via JS as everyone in company should have JS enabled. Link to comment https://forums.phpfreaks.com/topic/48983-solved-preventing-double-posts-on-a-form/#findComment-239981 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.