473,714 Members | 4,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preventing POST Again When User Clicks Back Button

I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?

--Bruce
Jul 17 '05 #1
5 4616
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:3t******** *************** *********@4ax.c om...
I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?

--Bruce


You could give it a form action of, say, "formhandler.ph p". On
formhandler.php , handle the information from the form (naturally), then send
the user via header("Locatio n: ...") to "success.ph p", which displays some
message like "The data was successfully submitted." The back button will
then send them to the original form, and the refresh button will just
refresh the success message. Either way, the form won't be re-POSTed.

If the data from the form needs to be immediately displayed, then save the
data from formhandler.php into $_SESSION variables and send a location
header to your display page.

- JP
Jul 17 '05 #2
I guess the problem occurs when I need to display the same page again,
like when I delete a line item in a list of items, or click on a link
to send a stock e-mail to someone.

--Bruce

On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
<je**********@c omcast.net> wrote:
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:3t******* *************** **********@4ax. com...
I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?

--Bruce


You could give it a form action of, say, "formhandler.ph p". On
formhandler.ph p, handle the information from the form (naturally), then send
the user via header("Locatio n: ...") to "success.ph p", which displays some
message like "The data was successfully submitted." The back button will
then send them to the original form, and the refresh button will just
refresh the success message. Either way, the form won't be re-POSTed.

If the data from the form needs to be immediately displayed, then save the
data from formhandler.php into $_SESSION variables and send a location
header to your display page.

- JP


Jul 17 '05 #3
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:0f******** *************** *********@4ax.c om...
I guess the problem occurs when I need to display the same page again,
like when I delete a line item in a list of items, or click on a link
to send a stock e-mail to someone.

--Bruce

On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
<je**********@c omcast.net> wrote:
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:3t******* *************** **********@4ax. com...
I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?

--Bruce


You could give it a form action of, say, "formhandler.ph p". On
formhandler.ph p, handle the information from the form (naturally), then sendthe user via header("Locatio n: ...") to "success.ph p", which displays somemessage like "The data was successfully submitted." The back button will
then send them to the original form, and the refresh button will just
refresh the success message. Either way, the form won't be re-POSTed.

If the data from the form needs to be immediately displayed, then save thedata from formhandler.php into $_SESSION variables and send a location
header to your display page.

- JP


In that case (if I understand your problem), you can still use the same form
action ("formhandler.p hp"), and from there, header() the user back to the
original page s/he was viewing. The page will then be updated with the new
(or deleted) records.

- JP
Jul 17 '05 #4
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:0f******** *************** *********@4ax.c om...
I guess the problem occurs when I need to display the same page again,
like when I delete a line item in a list of items, or click on a link
to send a stock e-mail to someone.

--Bruce

On Sat, 04 Sep 2004 23:45:32 GMT, "kingofkolt "
<je**********@c omcast.net> wrote:
"Bruce" <bv************ ***@mailblocks. com> wrote in message
news:3t******* *************** **********@4ax. com...
I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?

--Bruce


You could give it a form action of, say, "formhandler.ph p". On
formhandler.ph p, handle the information from the form (naturally), then sendthe user via header("Locatio n: ...") to "success.ph p", which displays somemessage like "The data was successfully submitted." The back button will
then send them to the original form, and the refresh button will just
refresh the success message. Either way, the form won't be re-POSTed.

If the data from the form needs to be immediately displayed, then save thedata from formhandler.php into $_SESSION variables and send a location
header to your display page.

- JP


In that case (if I understand your problem), you can still use the same form
action ("formhandler.p hp"), and from there, header() the user back to the
original page s/he was viewing. The page will then be updated with the new
(or deleted) records.

- JP
Jul 17 '05 #5
Hello,

On 09/04/2004 08:27 PM, Bruce wrote:
I have a number of forms that do significant work based on variables
POSTed from the form. What is the common method of detecting and
preventing this work from being done when the form is POSTed as the
result of the user clicking the Back or Reload buttons in the browser?


You may want to try this class that lets you specify a message that
appears on alert box when the users tries to submit the same form again.
It does not stop an user from submitting the same form again if he
really wants, but it prevents that many nervous users submit the same
form again by accident, which in my experience happens quite often:

http://www.phpclasses.org/formsgeneration
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #6

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

Similar topics

8
2338
by: CJM | last post by:
How do people go about preventing the user from submitting a form for a 2nd time? For example, the user submits a form, clicks on the back button, and the submits the form again. I have used various techniques in the past (depending on circumstances) but I'd be interested in the techniques you guys currently use. Thanks --
8
1891
by: Galahad | last post by:
Here's the question: I have a form w/ TextBox controls and a Search Button control. Once the user clicks the Search Button, they get a Modal dialog w/ a datagrid that contains their search results. They select a row and click OK. The return value of the Module triggers an method that populates the TextBoxes w/ values and disables them. After the TextBoxes are disabled, I change the text of the buton to "Search Again" since I have to...
3
1695
by: Ravi | last post by:
Hi, I have a simple .aspx page where user enters data (e.g Name address, etc). At the end, he/she clicks Save button which Posts to the same page and in the Save button's click event I am saving the data into Database. Now after saving the details the same page gets rendered to the user. If the user refreshes the browser as its a post - back page the server is trying to store the values again. what are the different possible ways to avoid...
4
5035
by: Diane Selby | last post by:
Hi- I am developing an ASP.NET application that can take a few seconds to process the request from the user. We are looking for a client-side solution that will prevent users from resubmitting the page multiple time in their irrational impatience. There are a few posts on this group which suggest that we use JavaScript hooked up to the page's OnSubmit event to catch mulitple submissions. See postings by Craig Deelsnyder et alia.
3
3101
by: Brian Henry | last post by:
I have two list boxes on my form... lstCanSend and lstRecipients... well then there are two buttons add and remove between them (your basic select and pick listing) which uses java script to move the items between list boxes (the listbox controls are server side ones with runat=server set on them, the buttons are basic html button i dont want to post back each time someone clicks on add or remove... that wastes time and bandwidth) well the...
6
3739
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many user get used to click "enter" key to submit a form. How can I use "enter" key to submit/postback in ASP.NET. Thank, Guoqi Zheng
10
3736
by: Oleg Konovalov | last post by:
Hi, I have a Java 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 records. So I am trying to disable the button as soon as it is clicked, and as soon as it's done, re-enable it again.
6
11896
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, and as soon as it's done,
2
6332
by: noneya22 | last post by:
I'm using asp.net 2.0. I have a page that has a save button and a cancel button along with a text field. All controls are asp.net server controls. I have JavaScript that prompts the user if he has maninpulated data in the text field and then tries to leave the page. The purpose is to prevent the user from accidentally losing his changes. This JavaScript code that accomplishes this is based upon the code found at...
0
8808
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8712
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9316
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9077
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9023
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7954
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4466
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2113
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.