Solved

how to avoid re-posted data

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
selecting both the price and sum(price ) with mysql statement 5 42
preventing spam with mailto 22 29
javascript: add id amounts 5 46
PHP AJAX JSON 2 57
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
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 …

813 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

8 Experts available now in Live!

Get 1:1 Help Now