CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 How to Prevent Duplicate Inserts from Browser Back Button

Print topic Send  topic

Author Message

Posts: 1
Posted: 01/25/2010, 5:35 AM

This is a Code Charge Studio Specific Solution (using PHP) to stop users from using browser back button then resubmitting a form which causes duplicate or additional unexpected records.

When a user browses back to a CCS Insert Form, it is still in insert mode from the last insert. If they click Insert again, it will create a duplicate record. If they change details then click insert, it will create a new additional record (not update the details or the original record which is typically what the user is trying to do).

1. Add a Hidden Field anywhere on the Form and name it Submitted

2. Add the following code to the Before Show Event for Submitted Hidden Field
     //Generate unique identifier to detect duplicate insert  
3. Add the following code to the Server On Click Event for the Forms Insert Button.
    if (!$Container->EditMode){ //Only an issue for insert mode. Edit (update) mode not effected  
      if($Container->Submitted->GetValue()==CCGetSession('last_'.$Container->ComponentName,'')) {  
        //If the current unique identifier matches the last one stored in the session variable  
        //then the page has not been reloaded and proceeding with the insert will cause a duplicate.  
        global $Redirect;  
      } else {  
        //Save the unique identifier for the this currently submitted form in a session variable using prefix and form name  
4. Create an error page such as error_duplicate_entry.php to notify something like:
Error: The System has detected an attempt to create a duplicate entry.  
This is usually a result of using the Browser Back button and submitting a form on a previous page again.   
The last changes you made before seeing this page have been discarded.    
Please use the link below to return to [somewhere]  
Please do not use the back button on your browser with this site.  
[Link to Somewhere]

If anyone has anything better or can improve this, please post for others to share.
View profile  Send private message

Posts: 151
Posted: 01/25/2010, 9:52 AM

Thanks for sharing!
View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.