Solved

Page Redirection

Posted on 2002-05-15
4
136 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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 …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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