473,554 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Idea for form action page to reduce double submissions

Hi,

I have been trying to come up with an idea to reduce double submissions
where a user clicks refresh and, for example, another row is INSERT
into a table.

Originally, I would have a form page. When a user submits the form (ie.
index.php), I would script it so that when the form action would be the
same page but it would use the address 'index.php?acti on=add'. This is
bad (mmm-kay) as when the user refreshes the page it would add another
row into the database table.

The solution (thanks to a reply on this newsgroup) is to have a
different page to carry out the form processing and depending on the
result either redirect them to a successful or unsuccessful page (or
the same page but different outcomes as a result of scripting).

Anyway, my idea is very similar to the above where a user will fill in
the form. They will then be submitted to a page called action.php. This
action page will deal with all scripting associated with this news
admin system I am planning, including add/edit/delete pages. They will
be dealt with by passing the rellevant instruction with the GET
parameters (ie. action.php?acti on=delete). Should an error be found
then it will be highlighted in the action page and a link back to the
form page will be provided with the values entered passed back using
POST variables. In the event of a successful entry, the user will be
redirected back to the form parent page (view article (parent) -> edit
article (child)) with passed GET info (ie. view.php?action =add) where
as it knows what action was carried out it can assume that it was
successful and the 'You have successfully added a news article' message
would be displayed.

Im pretty confident that this system would be a big improvement but
would be greatful if anyone who does this in a similar way would give
comment. Cheers

Burnsy

Aug 4 '05 #1
5 3761
After a submission is sent I repond with a page that loads the new page a
redirect I guess.

example:

str="/z/sn?command=cash flow&rec="+dynv ar["index"]
page="<body onload=\"window .location.repla ce('"+str+"');\ ">"+"<a
href=\""+str+"\ ">Cash Flow</a><BR><BR>"+chr (13)+page+"</BODY>"

basically the onload window.location .replace returns the browser to a fresh
page which will not enter a new record if refresh is clicked good luckOak
<bi******@yahoo .co.uk> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hi,

I have been trying to come up with an idea to reduce double submissions
where a user clicks refresh and, for example, another row is INSERT
into a table.

Originally, I would have a form page. When a user submits the form (ie.
index.php), I would script it so that when the form action would be the
same page but it would use the address 'index.php?acti on=add'. This is
bad (mmm-kay) as when the user refreshes the page it would add another
row into the database table.

The solution (thanks to a reply on this newsgroup) is to have a
different page to carry out the form processing and depending on the
result either redirect them to a successful or unsuccessful page (or
the same page but different outcomes as a result of scripting).

Anyway, my idea is very similar to the above where a user will fill in
the form. They will then be submitted to a page called action.php. This
action page will deal with all scripting associated with this news
admin system I am planning, including add/edit/delete pages. They will
be dealt with by passing the rellevant instruction with the GET
parameters (ie. action.php?acti on=delete). Should an error be found
then it will be highlighted in the action page and a link back to the
form page will be provided with the values entered passed back using
POST variables. In the event of a successful entry, the user will be
redirected back to the form parent page (view article (parent) -> edit
article (child)) with passed GET info (ie. view.php?action =add) where
as it knows what action was carried out it can assume that it was
successful and the 'You have successfully added a news article' message
would be displayed.

Im pretty confident that this system would be a big improvement but
would be greatful if anyone who does this in a similar way would give
comment. Cheers

Burnsy

Aug 4 '05 #2
I've been able to combat this problem with something like this
(requires the use of sessions):

1. When a page is loaded, generate some random id and store it in the
session as curpage_id. (Also do step #3).

2. When drawing a form, include a hidden parameter called page_id or
something and use the curpage_id as the value.

3. On the next page, put the curpage_id from the session into another
session variable called prevpage_id, and generate a new curpage_id.

4. Before processing your form (inserting rows, whatever) check that
the form parameter page_id equals the value of prevpage_id from the
session. If they do, you're good. If they don't the page must have
been refreshed.

Aug 4 '05 #3
ZeldorBlat wrote:
I've been able to combat this problem with something like this
(requires the use of sessions):

1. When a page is loaded, generate some random id and store it in the
session as curpage_id. (Also do step #3).

2. When drawing a form, include a hidden parameter called page_id or
something and use the curpage_id as the value.

3. On the next page, put the curpage_id from the session into another
session variable called prevpage_id, and generate a new curpage_id.

4. Before processing your form (inserting rows, whatever) check that
the form parameter page_id equals the value of prevpage_id from the
session. If they do, you're good. If they don't the page must have
been refreshed.


Doesn't this preclude the possibility of the user having multiple
windows open, and still being able to use your website? This would be awful.

Cheers,
Nicholas Sherlock
Aug 4 '05 #4
First of all, I don't care too much about my users since most of them
(that use the forms anyway) are my co-workers.

You are correct that this could be a problem. What would need to
happen is as follows:

Someone opens a page with a form.
Someone opens another page in a different window/tab.
Someone returns to the original form and tries to submit.

Nobody has complained about it yet (although they might). Since you
think that "this would be awful," perhaps you can suggest an
alternative?

Aug 5 '05 #5
ZeldorBlat wrote:
Nobody has complained about it yet (although they might). Since you
think that "this would be awful," perhaps you can suggest an
alternative?


Don't use sessions. I haven't tried this out, but how about this:

Say you have an action like making a post on a forum. You want to stop
people from pressing refresh or double clicking submit, but a large
percentage of users will be viewing/working on more than one post at a
time (Tabbed browsing). You have decided that a "time delay" system is
unacceptable for your users. You have the structure "New post page"
(Where your form lives) ->"Action page" (Which does the processing).

Store a global lastpostid counter in your database. Every time the new
post page is loaded, this id is incremented and written to a hidden
field in the form.

Store this id into every new post made. Then, if the action page
receives a post id from the hidden field which is already part of a post
in your database, the user has refreshed or double clicked. No time
delays, the users can use tabbed browsing.

Cheers,
Nicholas Sherlock
Aug 5 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5374
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says there is a sample file called Ixtrasp.asp, but I could not find it in my system although I installed indexing service. I followed the steps in MSDN...
15
6556
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The...
7
2000
by: degmsb | last post by:
With Java script when a user hits submit on a form on my site, is it possible to take the values from the form and submit them to another form on another Url without the user who submitted the form on my site knowing? Essentially ones the user on my site hits submit they would get a thank you page but on the back end I want to take the...
4
2711
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit". Ignoring the server side of things, does anyone see any holes with the following script? It seems to work, but I'd appreciate other eyes on it. Maybe a...
6
11874
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks again, which created duplicate forcm submission and hence duplicate records. So I am trying to disable the button as soon as it is clicked,...
9
4263
by: mosscliffe | last post by:
I am struggling to find a python example of the scenario - I have. I have a python script, which generates a page with a search button (actually an input field). The data from the above submissions is interrogated and the same script produces a new search option and the a page of results from the previous search request. - as done by...
1
3305
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway (ContactGateway.cfc) - index.cfm - Deals with the business logic - display/form.cfm - Produces the form for both add and edit behaviour
14
3367
by: Ed Jay | last post by:
Despite searching the net, I can't find a suitable solution that prevents a user's double click from submitting a form twice. I'm currently using the following in a button element: <input type="button" onclick="this.disabled=true;this.form.submit();"> While it prevents multiple single clicks, it isn't good enough for a fast double click,...
0
7814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7576
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5165
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3583
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.