By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Refresh/Double Submit problem

P: n/a
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
Share this Question
Share on Google+
15 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.