Solved

how to avoid re-posted data

Posted on 2007-03-26
3
176 Views
Last Modified: 2008-02-01
Hi
I have noticed that if the user clicks the back button (warning box opens about re-posted data) the data is inserted again into mysql.
I need to avoid this happening. The page is posted to itself and stops when the uploaded data is succesfully loaded into mysql, it then offers a number of links to the user, clicking the back button is one I want to avoid. I have thought of using HTTP_REFERRER to check the page it has come from and header("Cache-Control: no-cache, must-revalidate"); to clear the cache.
I would like to know what an expert would do
Many thanks
0
Comment
Question by:TonyHull
3 Comments
 
LVL 6

Accepted Solution

by:
deresh earned 180 total points
ID: 18791394
you could do a unconditional redirect after you store your data from POST into database. that should reset post data.
0
 
LVL 17

Assisted Solution

by:psimation
psimation earned 160 total points
ID: 18791522
or you could create a session variable that holds a "page loaded" value. For instance, before you write, you have a check to see if the session variable contains something, if it does, you don't write to db, if it's empty, you write to db, plus put a value in session var.

0
 
LVL 4

Assisted Solution

by:Mr-Ene
Mr-Ene earned 160 total points
ID: 18814628
before every page generation, generate a random hash. place in in a hidden input, and store it, and the previous value in session.

check if they match after post.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now