Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Page Redirection

Posted on 2002-05-15
4
Medium Priority
?
141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 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