Link to home
Start Free TrialLog in
Avatar of CDirenzi
CDirenziFlag for United States of America

asked on

If page is refreshed data is written twice to database

I have an HTML form that gets user info and when they press the submit button it will add the data to the database and then display the information they just added.  When the user is on the confirm page, if he pushes refresh it will resubmit the data to the database.  I cannot check to see if the row already exists, because it is okay for there to be multiple rows that are the same (just with a different time stamp).  What is the best way to prevent this from happening?  Thanks!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

check out this script to be added to your page:
<script language="JavaScript">
function validate(){
if(document.inputform.field1.value != ""){
if(document.inputform.field2.value != ""){
document.inputform.submit.disabled = false;
}
}
}
function disable(){
document.inputform.submit.disabled = true;
document.inputform.submit.value = "Please wait... Form is being
submitted.";
}
</script>

Open in new window

SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial