Avoid double posting example

When you access the web site using input for, you sometimes push back button after submit, or push the button again before the web page changes. Then the request to process the form data twice. In this page, I'll show you how to avoid the double post by using example.

Access the example

In order to access this example, please access the url below or "Avoid double posting samples" link from the toppage.

http://localhost:8080/samples/avoidrepost/

Then the page below will appear.

avoid double posting

In this page, submit a name, and push back button in the browser. And resubmit the form by pushing "Submit yout name".

Back button in the browser

At the first access, the operation for the form data is executed, but next time, the operation is ignored. The detai is in the implementataion.

Implementation

The source code of this example is in "ALINOUS_HOME/samples/avoidrepost/" folder.

avoid double posting example folder

The implementation of "index.alns" in this folder is below.

In this sample, it checks if the operation from the inpurt from has been done or not by calling "AccessToken.check()". The implementation of "AccessToken.check()" is below.

/include/accesstoken.alns

This function checks if the access token is already in the database table or not. The access token is generated automatically by Alinous-Core.

The hidden parameter ACCESS_TOKEN is automatically generated, and this is unique for access in the same session. So the primary key of double_button_lock is session_id and access_token.


Go to Top