Solved

Page Redirection

Posted on 2002-05-15
4
128 Views
Last Modified: 2013-12-24
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...
0
Comment
Question by:the_kid
4 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 7012409
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()" ...
0
 
LVL 14

Accepted Solution

by:
SBennett earned 50 total points
ID: 7012594
another thing you could do is to set a session variable in the action page once the form has been submitted and check for it's value before processing the form.

<cfparam name="Session.ThisFormWasProcessed" default="0">

<cfif Session.ThisFormWasProcessed>
 This form was already processed. You can't do it again
<cfelse>
 ...code to process form goes here...
<cfset Session.ThisFormWasProcessed = 1>
</cfif>
0
 
LVL 1

Expert Comment

by:Agatheeswaran
ID: 7013111
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.
 
0
 

Author Comment

by:the_kid
ID: 7013503
Thanks...this seems like the easiest solution
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now