473,408 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Refresh/Double Submit problem

ABC
Hi,

I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.

***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.

My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?

I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.

I hope, i have been able to express my problem clearly.

Please help!

Raghu

May 7 '07 #1
15 4932
On May 7, 4:44 pm, ABC <raghuana...@gmail.comwrote:
Hi,

I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.

***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.

My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?

I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.

I hope, i have been able to express my problem clearly.

Please help!

Raghu
I dont think it is possible.. if you only want to do it server side
then the post has to complete and the resulting page has to load
before you can output anything to the screen.. since you are able to
see if there has been two submissions why not take them to an error
page saying go back and dont hit submit twice this time..

Flamer.

May 7 '07 #2
ABC
On May 7, 10:08 am, "flamer die.s...@hotmail.com"
<die.s...@hotmail.comwrote:
On May 7, 4:44 pm, ABC <raghuana...@gmail.comwrote:


Hi,
I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.
***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.
My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?
I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.
I hope, i have been able to express my problem clearly.
Please help!
Raghu

I dont think it is possible.. if you only want to do it server side
then the post has to complete and the resulting page has to load
before you can output anything to the screen.. since you are able to
see if there has been two submissions why not take them to an error
page saying go back and dont hit submit twice this time..

Flamer.- Hide quoted text -

- Show quoted text -
Hi,

What if i have some DB Inserts/Updates which takes time ?
That solutions sound little primitive and then again, if i take him to
an error page, then the previous output does not come to the browser i
suppose!

May 7 '07 #3
On May 7, 6:44 am, ABC <raghuana...@gmail.comwrote:
I have a problem with Double submission in html forms.
Did you try disabling the submit button using JavaScript?

good luck
Martin
------------------------------------------------
online accounting on bash bases
Online Einnahmen-Ausgaben-Rechnung
http://www.ea-geier.at
------------------------------------------------
m2m server software gmbh
http://www.m2m.at

May 7 '07 #4
ABC wrote:
Hi,

I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.

***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.

My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?

I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.

I hope, i have been able to express my problem clearly.

Please help!

Raghu
Hmmm, let's see.

How about the page you're posting to outputs a "Please wait" and flushes
the output, then starts processing. Might not work in all browsers -
but in most it should clear the screen and give the "please wait" message.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 7 '07 #5
ABC
On May 7, 7:26 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ABC wrote:
Hi,
I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.
***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.
My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?
I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.
I hope, i have been able to express my problem clearly.
Please help!
Raghu

Hmmm, let's see.

How about the page you're posting to outputs a "Please wait" and flushes
the output, then starts processing. Might not work in all browsers -
but in most it should clear the screen and give the "please wait" message.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Hi Thanks for your help so far,

I have heard the struts framework supports Synchronizer token pattern
to handle this kind of problem.
But didnt understand it well. I suppose this is a common problem
encountered..

Do let me know your thoughts on this...

May 9 '07 #6
On May 9, 7:52 am, ABC <raghuana...@gmail.comwrote:
On May 7, 7:26 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ABC wrote:
Hi,
I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.
***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.
My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?
I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.
I hope, i have been able to express my problem clearly.
Please help!
Raghu
Hmmm, let's see.
How about the page you're posting to outputs a "Please wait" and flushes
the output, then starts processing. Might not work in all browsers -
but in most it should clear the screen and give the "please wait" message.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -

Hi Thanks for your help so far,

I have heard the struts framework supports Synchronizer token pattern
to handle this kind of problem.
But didnt understand it well. I suppose this is a common problem
encountered..

Do let me know your thoughts on this...
Personally, when a form is submitted, I have it directed to a page
that displays no html, and does the server-side verification and
inserts into DB and _then_ I use header("Location: /address/to/
thankyou/"); where it will display information about what will be done
with the information, a thank you bit, and an email will be sent. This
avoids Refresh/Double Submit problem because the back button will
direct them to the form!

May 9 '07 #7
ABC wrote:
On May 7, 7:26 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ABC wrote:
>>Hi,
I have a problem with Double submission in html forms.
I am using PHP as the server side scripting language, i have found a
means to capture the second form submission while the first form
submission is still in-progress. Basically, i can use sessions to
check if the first submission is active and reject subsequent submits.
***I do not want to try any client side solution(such as disabling
submit button) as hitting F5 on the screen will re-post the data
again.
My question is :
(*) if i send some kind of output to the browser telling the user
that a previous session is active, then how do i ensure that the first
form submission's output is displayed to the user on the browser
window?
I tried, print messages like- Please wait. But somehow the first form
submission's output is not printed...I am guessing the browser closes
the connection after the second submission's output is received and
first submission has no where to send the output.
I hope, i have been able to express my problem clearly.
Please help!
Raghu
Hmmm, let's see.

How about the page you're posting to outputs a "Please wait" and flushes
the output, then starts processing. Might not work in all browsers -
but in most it should clear the screen and give the "please wait" message.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Hi Thanks for your help so far,

I have heard the struts framework supports Synchronizer token pattern
to handle this kind of problem.
But didnt understand it well. I suppose this is a common problem
encountered..

Do let me know your thoughts on this...
Sorry, I've never used it. But I suspect it does something similar.

Any way you go, you have to follow what the protocol, server and client
do. No framework can bypass that.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 9 '07 #8
ABC
When i refresh the browser window/screen, does the browser close the
previous connection or does it still keep it open.

Is there no work around for this...
I have read that at the php side, when the script tries to output
something, it sees that the other end has closed the connection,
during which time the script stops working...

May 29 '07 #9
ABC wrote:
When i refresh the browser window/screen, does the browser close the
previous connection or does it still keep it open.

Is there no work around for this...
I have read that at the php side, when the script tries to output
something, it sees that the other end has closed the connection,
during which time the script stops working...
The current connections (if any) would be closed and the browser starts
fresh with a brand net request.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 29 '07 #10
ABC
Is there any article that you can direct me to? so that i can
understand the browser internal workings...
Any help on this appreciated

May 29 '07 #11
ABC wrote:
Is there any article that you can direct me to? so that i can
understand the browser internal workings...
Any help on this appreciated
None that I know of, unfortunately. But then I haven't looked.
Although I do understand how the browser works, I've never found it
necessary to code my pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 29 '07 #12
On May 29, 12:55 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ABC wrote:
Is there any article that you can direct me to? so that i can
understand the browser internal workings...
Any help on this appreciated

None that I know of, unfortunately. But then I haven't looked.
Although I do understand how the browser works, I've never found it
necessary to code my pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
This has been a common problem ever since first submit forms appeared
on the Internet. It has been solved in different ways, but each one of
them has its own issues. Recently, however, the Ajax technique has
become quite popular and it's, in my opinion, the perfect way (and the
best) to solve this kind of problem - let the submit button not have
"type=submit" but rather "type=button
onclick=send_post_data()" (pseudo code). Of course, you can then take
him to another page, if you want, or you can just update the current
page reflecting the status of his request. In this way, you can
manipulate whatever you want (hide the button after clicking, disable
it, whatever, or even let it be enabled but give a warning on the
second click etc), f5 doesn't mean "resubmit", and everything is
perfect. Of course, a cracker may always manually open the connection
to your processing script, but that's something that can't be overcome
in theory, thus not in practice neither, since you can't stop anyone
from calling your script. You can only stop accidental resubmits, and
that's the whole point.

May 29 '07 #13
rf

"ABC" <ra*********@gmail.comwrote in message
news:11**********************@r19g2000prf.googlegr oups.com...
When i refresh the browser window/screen, does the browser close the
previous connection or does it still keep it open.
There is not previous connection. HTTP is stateless.

A "browser refresh" is a brand new request to the server.
May 29 '07 #14
Darko wrote:
On May 29, 12:55 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ABC wrote:
>>Is there any article that you can direct me to? so that i can
understand the browser internal workings...
Any help on this appreciated
None that I know of, unfortunately. But then I haven't looked.
Although I do understand how the browser works, I've never found it
necessary to code my pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

This has been a common problem ever since first submit forms appeared
on the Internet. It has been solved in different ways, but each one of
them has its own issues. Recently, however, the Ajax technique has
become quite popular and it's, in my opinion, the perfect way (and the
best) to solve this kind of problem - let the submit button not have
"type=submit" but rather "type=button
onclick=send_post_data()" (pseudo code). Of course, you can then take
him to another page, if you want, or you can just update the current
page reflecting the status of his request. In this way, you can
manipulate whatever you want (hide the button after clicking, disable
it, whatever, or even let it be enabled but give a warning on the
second click etc), f5 doesn't mean "resubmit", and everything is
perfect. Of course, a cracker may always manually open the connection
to your processing script, but that's something that can't be overcome
in theory, thus not in practice neither, since you can't stop anyone
from calling your script. You can only stop accidental resubmits, and
that's the whole point.
Yes, that's one way of doing it. But the problem with that is it
requires javascript to be active on the user's browser, and more and
more users seem to be disabling javascript nowadays for security reasons.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 29 '07 #15
Yo,

Like everyone has mentioned, this has been around for ages. Here is one
of many solutions.
http://www.theserverside.com/tt/arti...irectAfterPost

I first encountered this in my Java days, basically the way i went
around it was to create a unique form id for each form and place it
inside the users session. When the user tried to re-submit, logic would
check that a form session id was not already set. Once the user left the
page the session would null out. :-)

Armando Padilla


Jerry Stuckle wrote:
Darko wrote:
>On May 29, 12:55 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>>ABC wrote:
Is there any article that you can direct me to? so that i can
understand the browser internal workings...
Any help on this appreciated
None that I know of, unfortunately. But then I haven't looked.
Although I do understand how the browser works, I've never found it
necessary to code my pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

This has been a common problem ever since first submit forms appeared
on the Internet. It has been solved in different ways, but each one of
them has its own issues. Recently, however, the Ajax technique has
become quite popular and it's, in my opinion, the perfect way (and the
best) to solve this kind of problem - let the submit button not have
"type=submit" but rather "type=button
onclick=send_post_data()" (pseudo code). Of course, you can then take
him to another page, if you want, or you can just update the current
page reflecting the status of his request. In this way, you can
manipulate whatever you want (hide the button after clicking, disable
it, whatever, or even let it be enabled but give a warning on the
second click etc), f5 doesn't mean "resubmit", and everything is
perfect. Of course, a cracker may always manually open the connection
to your processing script, but that's something that can't be overcome
in theory, thus not in practice neither, since you can't stop anyone
from calling your script. You can only stop accidental resubmits, and
that's the whole point.

Yes, that's one way of doing it. But the problem with that is it
requires javascript to be active on the user's browser, and more and
more users seem to be disabling javascript nowadays for security reasons.
Jul 30 '07 #16

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

Similar topics

4
by: Noel Wood | last post by:
Hello, I have a problem that I'm sure is simple but I have searched the newsgroup and have not found it posted before so I apologize if it has been asked heaps of times before. I have a page that...
7
by: kindermaxiz | last post by:
I have a php script with a form that insert data in a mysql db and when I click on submit I would like the page to refresh after the insertion, how can I do that? it's a php script that display...
3
by: Ice Man | last post by:
Hi I want to send e-mails using an asp page first I create the mail Object: Set objMail = Server.CreateObject("CDONTS.NewMail") After I fill a variable with the html code that will be the...
1
by: davegraham_1998 | last post by:
Hi All- I'm pretty sure this have been discussed earlier, but couldn't find a solution to my problem. <input type="submit" value="Delete Parts" onclick="return handleDeleteParts('ABC', 'MY...
2
by: Darryl A. J. Staflund | last post by:
Hi there, Can anyone tell me why invoking a single SQL insert statement (well, rather, a method that performs a SQL insert) using an asynchronous delegate should result in twice the number of...
1
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that...
1
by: GregG | last post by:
This is information for those who may have been bitten by the "double-post" problem in GridView controls. I've been messing with ASP.Net about a week, and have uncovered an annoying 'feature'....
1
by: DarthOptimus | last post by:
Hi, There is javascript code on my jsp to prevent double submission of a form: <SCRIPT type="text/javascript" language="JavaScript"> var firstSubmit = true; function isFirstSubmit() {
0
by: josephkorn | last post by:
Hi all. I have a problem in my website in trying to prevent a user from double submitting the form. I am calling a subroutine from my page_load event that passes in the commandbutton that I want...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.