Solved

how to avoid re-posted data

Posted on 2007-03-26
3
175 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

18 Experts available now in Live!

Get 1:1 Help Now