Solved

how to avoid re-posted data

Posted on 2007-03-26
3
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

695 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