473,386 Members | 1,674 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,386 software developers and data experts.

About 'resend form information' when i hit 'BACK' button

16
Hi, guys

sorry if this kind of question had been asked before and kinda newbie question. coz i'm new to programming and just couldn't figure it out yet...

My problem is:

I have a form that POST variables and execute function in the target page (That function happens to be sending email).
If i hit the back button, the browser asks me if i'd resend the information again. And thus, the email would be sent again.

My question is:

Is there any best practice or some kind of techniques to overcome this tipical problem? Coz i know disabling the BACK button would be very bad idea and i don't like it either.

I tried to capture the isset(POST['submit']) parameter so that the code would only executed if i ACTUALLY hit the SUBMIT button.

But, apparently, the BACK button is somekind like 're-doing' my actions (as if i was actually hit the submit button)

I tried the history.go(1) techniques, but it only works in IE. I want it works for cross browsers.

Thanks alot...
Oct 20 '08 #1
5 4887
iam_clint
1,208 Expert 1GB
There is a way to do this if I remember correctly you do it as follows
page a -> post to pageb -> transfers you to pagec without writing anything
and in this method when you hit back it goes from pagec to pagea.. and doesn't want to retransmit the data.
Oct 20 '08 #2
Atli
5,058 Expert 4TB
I was working on a similar problem the other day.

What I did was create a random string (a hash), which I stored in a session variable and echoed into a hidden <input> element in my form page.

Then, once the data had been submitted, I had my action page match the session variable to the value of the <input> element. If they matched, I unset the session variable and processed the form. If they didn't I simply redirected the user back to the form page.

This only allows each form to be submitted once, requiring a new random string for each submission.
Oct 20 '08 #3
agun
16
Thanks Clint and Atli,

You've been really helpful. Now i have a slight idea about how to do it. I'll try your suggestion.

Thanks
Oct 21 '08 #4
agun
16
wow, thanks Clint and Atli,

I tried your suggestion, i make random number, store it in session variable, pass it to hidden input element in the action form and in the action page i compare with the POST variable. and it works!

So, if user hit BACK button, it won't be a problem now, coz the session doesn't match with the POST.

Thanks guys...
Oct 21 '08 #5
acoder
16,027 Expert Mod 8TB
In case you're interested, the method Clint was referring to is Post/Redirect/Get (PRG).
Oct 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andy Kasotia | last post by:
I have an ASP UI with VB Dll as a COM object that access the DB2 Database. I have a "Calculate" button on the ASP Page which when clicked does form validation (javascript) and submits the form...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
1
by: Developer | last post by:
We have an InterNet Application that does not use cookies, session variables, persistant cookies etc. But we collect the information on multiple forms (about 6 steps). Also we cannot count the...
3
by: Ken Varn | last post by:
I have Page1 that does a transfer to page2. When the user is done with Page2, there is a button on Page2 that they can press to bring them back to Page1. I use Server.Transfer to navigate from...
3
by: hermand | last post by:
I've got an online job application I am building using ASP/VBScript. The application consists of one ASP document which has three separate states. States: 1. Form Display 2. Form Review...
3
by: michdoh | last post by:
Hi All I'm looking for some help on creating a basic multi threaded application. i'n new to threads in this environment so for test purposes I've produced a very basic program. (which doesn't...
18
by: Fester Bestertester | last post by:
Greetings, I'm an occasional php/mysql dabbler. I have a basic data form with a submit button. Unfortunately, it's still possible for the user to enter data changes and close the window,...
4
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, How can I prevent from an ASP.NET page to resend all the data again when the user press the Refresh button or F5 on the browser? Thanks in advanced, Asaf
1
by: BillG | last post by:
I am developing a business app using asp.net that will have 2 different types of forms, a list view of data and then a detail view. The list views are placed on a content panel in a master page. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...

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.