• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

how to avoid re-posted data

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
TonyHull
Asked:
TonyHull
3 Solutions
 
dereshCommented:
you could do a unconditional redirect after you store your data from POST into database. that should reset post data.
0
 
psimationCommented:
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
 
Mr-EneCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now