
November 26th, 2008, 11:45 AM
|
|
Me
|
|
Join Date: Apr 2007
Location: San Diego, CA
Posts: 2,069

Time spent in forums: 1 Week 6 Days 7 h 49 m 29 sec
Reputation Power: 5
|
|
why can't you just get the id from the insert and redirect to the same page passing the id then use that to get the data out and build/show the receipt.
PHP Code:
if(isset($_POST) && !empty($_POST)){
//insert sale information
mysql_query("INSERT INTO Table VALUES($test, {$_POST['whatever']})");
//get
$id = mysql_insert_id();
header("Location: ?id=$id");
} else {
if(isset($_GET['id'])){
//query using id
$result = mysql_query("SELECT * FROM Table WHERE ID={$_GET['id']}");
//get row data
$row = mysql_fetch_assoc($result);
//echo receipt data
}
}
pretty much the only way you can prevent someone from re-inserting the data after a refresh would be one of three ways. First would be a redirect. Second would be to use some sort of session and remove the data or add a insert variable after it has been inserted and only insert if the data exists in the session or the insert variable is absent. Third would be to check that the data doesn't previously exist before inserting, which can be easy too if you assign a unique id to each sale that you save in session/database. Then you just check if that id is already in there and if not, insert, if so, update or don't do anything(maybe mark the receipt as a reprint).
|