473,626 Members | 3,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I keep from reprocessing forms?

This is my problem.

I want to submit a form to another page to process the data from said form.
Then the person can go on to another part of the site or another site
altogether. However If the person later clicks the <back button> enough
times they will arrive back at the page that processed the data the first
time and the same data will be processed again. How can I prevent this?
My first thought was to use a cookie and set it on submit of the form but I
have not been able to get that to work. Any suggestions?
-Alex
Jul 17 '05 #1
3 3201
I'm just getting into this, but I understand the following should work:

calling page:
....
<form method="POST" action="page2.p hp">
....
<input type="text" name="searchtex t" size="50">
<input type="submit" value="search">
</form>
....

Page you don't want to reprocess (page2.php):
....
$searchtext = $_POST[searchtext];
if (isset($searcht ext))
{
unset ($searchtest);
... do everything else...
}

"Alex Thomas" <al*********@mi ndspring.com> wrote in message
news:pi******** *********@newsr ead2.news.atl.e arthlink.net...
This is my problem.

I want to submit a form to another page to process the data from said form. Then the person can go on to another part of the site or another site
altogether. However If the person later clicks the <back button> enough
times they will arrive back at the page that processed the data the first
time and the same data will be processed again. How can I prevent this?
My first thought was to use a cookie and set it on submit of the form but I have not been able to get that to work. Any suggestions?
-Alex

Jul 17 '05 #2

On 26-Oct-2003, "Jenkins" <ne**@djenkins. nu> wrote:

"Alex Thomas" <al*********@mi ndspring.com> wrote in message
news:pi******** *********@newsr ead2.news.atl.e arthlink.net...
This is my problem.

I want to submit a form to another page to process the data from said

form.
Then the person can go on to another part of the site or another site
altogether. However If the person later clicks the <back button>
enough
times they will arrive back at the page that processed the data the
first
time and the same data will be processed again. How can I prevent
this?
My first thought was to use a cookie and set it on submit of the form
but

I
have not been able to get that to work. Any suggestions?

I'm just getting into this, but I understand the following should work:

calling page:
...
<form method="POST" action="page2.p hp">
...
<input type="text" name="searchtex t" size="50">
<input type="submit" value="search">
</form>
...

Page you don't want to reprocess (page2.php):
...
$searchtext = $_POST[searchtext];
if (isset($searcht ext))
{
unset ($searchtest);
... do everything else...
}

Sorry, this won't work because reprocessing page2.php will repost the form
fields.

AFAIK the only way to avoid the refresh/back problem is to use a session
variable to keep track of what's been posted and refuse the repost.
--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)
Jul 17 '05 #3
One possibility would be to check if this user has posted data already
and ignore it if he/she has.
This is simple if you are taking form data and placing it inside of a
database. Not so simple if something else is being done... i.e. An
customer service email script.
I have a site, where users can purchase items. To do so they have to
fill in a signup form. Obivously we only want each user to have one
account, but double clicking submit would normally create a new
account for them, so here is what I do.

I check the "critical information" against the database, if it exists
I just ignore the input. It looks something like this.

$critical_info = $_POST['email'];

$query = "SELECT * from mytable WHERE email ='$critical_inf o'";
$result = mysql_query($qu ery);

if(!$result){
//Do whatever it is I need to do to sign this customer up

}else{
echo <<< EOF
Sorry but it appears you've already signed up!<br>
<a href= "mysite.com/lostpass.php">C lick here to retrieve your
password</a><br>
EOF;
}

So basically, if you are storing the information, just check to see if
you already have the information before accepting it. If yes ignore,
otherwise store.

I hope this helps.

"Alex Thomas" <al*********@mi ndspring.com> wrote in message news:<pi******* **********@news read2.news.atl. earthlink.net>. ..
This is my problem.

I want to submit a form to another page to process the data from said form.
Then the person can go on to another part of the site or another site
altogether. However If the person later clicks the <back button> enough
times they will arrive back at the page that processed the data the first
time and the same data will be processed again. How can I prevent this?
My first thought was to use a cookie and set it on submit of the form but I
have not been able to get that to work. Any suggestions?
-Alex

Jul 17 '05 #4

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

Similar topics

2
13305
by: Patrick | last post by:
Hello, I have a drop down list that when a value is selected the page refreshes itself but the selected value changes back to the default value. I would like to keep the selected value after the page is refreshed. any ideas? Thanks in advance. Patrick
5
2428
by: Dani | last post by:
Hello everybody, I have some code that disables form elements on body load, but I notice when I hit the "back" button, I need to re-enable the form elements (that is done by clicking on a radial button). Is there any way I can keep the form for disabling every time a user hits the back button and "remember" what elements should be enabled? I was thinking maybe utilizing some referrer thing, but I'm not that good with JS yet. Thanks...
1
1466
by: Robert | last post by:
What I would like to do is set my database so that the users can add, change, and delete data on the forms and print the reports, but not modify the forms, the reports, the table layouts, or use the datasheet to modify tables. How do I do this? Robert
4
4574
by: Brian Basquille | last post by:
Hello all, Quick question! How would i keep a point inside a region? For example, the mouse pointer. You should be able to move the mouse around in this region but not anywhere outside it. How would i go about doing this?
1
2264
by: Peter Morris [Droopy eyes software] | last post by:
Hi all In my login form (forms authentication) I check that the login is valid, retrieve an "Author" object, and keep track of the author's roles. string roles; if (author.IsAdministrator) roles = new string {"Admin", "Member"}; else roles = new string {"Member"};
5
1524
by: sherifffruitfly | last post by:
Hi all, I'm certain this is stupid, but I'd like to know how to keep a form open for, say, longer than 1ms. Here's the code I'm using to open my form: TestModelFileReaderForm modelInfo = new TestModelFileReaderForm(); modelInfo.txtModelInfo.Text = elementInfo; modelInfo.Show();
1
4012
by: nkoriginal | last post by:
Hello Again: I've a problem with my forms. I woking with an intranet, and the pages in that intranet, has a reload page, every 10 minutos. So my problems star, when any user stay in my forms for more longe than 10 minutes, and the page reload, the user lose all data in that forms, if he not did submit. I want to keep the user form data, after reload. Is that possible? so, en litle words, if the user stay in my forms and he filled...
5
6799
by: Shane | last post by:
How do you keep a form on top of an application only. I know that I can use "TopMost" to keep a form on top of the other forms, but that solution is Windows scope instead of only my application scope. I have a floating "Totals" screen (among others) so that a user can see which checks will print, total receipts, and other items. They can resize the form, and move it anywhere on the screen, so creating a dock area on the screen is not...
11
9287
by: cty0000 | last post by:
I have some quiestion... I want to draw line,point,rectangles and etc... on the from So I code like this.. public update() { g = this.CreateGraphics(); g.FillRectangle(Brushes.White, x1, y1, x2, y2); }
0
8262
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
8196
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
8701
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...
0
8637
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
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
8502
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
4090
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...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.