Page 1 of 1
[SOLVED] stopping a refresh?
Posted: Wed Oct 27, 2004 6:55 am
by irealms
is there a way to stop a page being refreshed or stopping someone from hitting "back" and then going forward again?
Problem is i have an order page but don't want people to be able to place the order again, can't check for orders already in as the id is an auto incremement so is only created on entry into the db.
i did think about a check at the top of the order entry file to see what orders have been placed today by the user but the problem then is they may want to place another order or to place a duplicate.
Posted: Wed Oct 27, 2004 7:57 am
by CoderGoblin
One common tactic is to use the php:
to move rather than direct links whatever. This overwrites the browser history location rather than creating a new entry.
(Also commonly used for $_POST processing to avoid repetitive entries into a database=.
Example place_order.php script.
Code: Select all
<?php
if($order_valid) {
// Write Order:
header("Location=order_placed.php?ordid=$ordid");
exit;
}
// other calculations
?>
When the user selects back multiple times and then forward the order_placed.php is shown rather than place_order.php.
If the user presses links on the previous screens however they are activating part of the workflow. The normal method is to therefore empty the cart as part of the order_placed script.
Posted: Wed Oct 27, 2004 8:43 am
by vigge89
otherwise you could maybe use sessions, like setting a variable when you do the order, and then unset it when it have been processed, no idea, haven't done this before

Posted: Wed Oct 27, 2004 7:04 pm
by rehfeld
i use sessions for this, like vigge89 suggested
Code: Select all
<?php
if (they submitted an order and you accepted it)
$_SESSION['order_complete'] = true;
}
// then, just check for the existance of the session variable
if (!isSet($_SESSION['order_complete'])) {
// process the order
} else {
echo 'order already submitted';
}
?>
Posted: Thu Oct 28, 2004 2:50 am
by CoderGoblin
rehfeld wrote:i use sessions for this, like vigge89 suggested
Code: Select all
<?php
if (they submitted an order and you accepted it)
$_SESSIONї'order_complete'] = true;
}
// then, just check for the existance of the session variable
if (!isSet($_SESSIONї'order_complete'])) {
// process the order
} else {
echo 'order already submitted';
}
?>
The trouble with this approach is what to do if the person requires a new order. When do you switch this flag variable off ? If you use this approach you will need to reset the flag when a customer adds something to the cart after the order. Then if you go back and forward you still run into the old order creation... Solution: Create a new session for the person on order completion.
Posted: Thu Oct 28, 2004 2:50 am
by irealms
yeah i thought about using sessions for it, i'll have to set them for username and price i think, as we want users to be able to place other orders in same day, but the chances of them placing them for the same price are slim so i'll use that.
