Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Page Redirection

Posted on 2002-05-15
4
Medium Priority
?
143 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:
Scott Bennett earned 200 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
What You Need to Know when Searching for a Webhost Provider
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

972 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