faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

605 of 1194 people (51%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can is stop a user from pressing the submit button twice on a php/mysql data entry form?

Dec 3rd, 2006 18:09
Jorge Cordero, Tobias Mitter, Chris Kings-Lynne, Monte Ohrt, steve moffat, Ben Udall, jorge@delahorro.com


HIDDING USING JAVASCRIPT
To stop this to happen you can change the visibility property to false 
or hidden that way the button wont show anymore
that way the user doesnt get confused clicking again
(this is not to prevent when the user hits the back Button)
<html>
[...]
<script language:"javaScript">
function hideMybutton(){
var myForm = document.formName;
myForm.mySubmitbutton.style.visibility="hidden";
alert("The Form has been sent please wait");
}
</script>
<body id="b1">
[...]
<form name="formName">
<input type="button" value=" submit " 
onClick="hideMybutton();" name="mySubmitbutton">
</form>
[...]
</body>
</html>
have fun
Jorge