Link to home
Start Free TrialLog in
Avatar of the_kid
the_kid

asked on

Page Redirection

I have a processing page (act_process.cfm) that does an insert into the DB. Once somebody reached this page I want to make sure they don't click the "back" button in the browser and re-submit. Does anybody know how I can get around this? Thanks...
Avatar of danrosenthal
danrosenthal

Disabling the back button is not a good approach. There should be a trigger somewhere that prevents duplicate submissions.  A javascript function that is called before the form is submitted would work. When the function is called it checks a variable to see if it equals 0 and only submits the form if it does, and then sets the variable to 1, so that the form may not be re-submitted without refreshing the page.

<SCRIPT LANGUAGE="javascript">
formsubmitted=0
function chkform(){
  if(formsubmitted==0){
    formsubmitted=1;
    return true;
  }else{
    alert("Form has already been submitted!");
    return false
  }
}
</SCRIPT>

<FORM ONSUBMIT="return chkform()" ...
ASKER CERTIFIED SOLUTION
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America 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
One Better Idea what I can suggest is that, before INSERTing into the table, first try to select that record with the keys, then check the recordcount.

If recordcount is greater than 1 then don't insert, else insert into the table.

Thanks

Aga.
 
Avatar of the_kid

ASKER

Thanks...this seems like the easiest solution