Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Reload a page and redirect?

New Here ,
Sep 14, 2007 Sep 14, 2007
I am developing website for user to submit a form online. I have insertAction page1 that serves for this need. When a user fills the stuffs on insertAction1 and hit submit button, it then calls inserAction2 page to display the data. In the meantime, the data go into the backend database.

Here is my problem, however, if the user reloads or refreshes the browser while he is at insertAction page2. All the insert data will be duplicated. Is there any way in ColdFusion or JavaScript to avoid that or redirect to the update page? If so, how? Do you have any existing code that I can use?

Thanks for your help.

Frank

TOPICS
Connector
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2007 Sep 14, 2007
i think the standard way of doing it is sufficient for your purposes. First, let the form do a post to the action page. Second, wrap the code in the action page around a construction similar to <cfif isDefined("form.aFormField")></cfif> . You should therefore end up with something like

insertAction1.cfm
===============
<form action="insertAction2.cfm" method="post">

insertAction2.cfm
===============
<cfif isDefined("form.aFormField")>
<!--- data validation, business code such as inserting data, etc.--->
</cfif>

Then the only way to insert data is to submit a form to insertAction2.cfm.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2007 Sep 17, 2007
LATEST
BKBK, Peter,

using <cflocaion> does solve my problem. Thank you all so much!

- Frank
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 14, 2007 Sep 14, 2007
I always redirect the user to another page after the action page is finished inserting or updating information. Usually I just go back to the original form page, this way the user can see that the information was updated. You can also put a message on this page saying that the information was submitted, deleted, updated, etc.

Peter
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 14, 2007 Sep 14, 2007
use <cflocation url="page1.cfm">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources