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.
[SOLVED] stopping a refresh?
Moderator: General Moderators
[SOLVED] stopping a refresh?
Last edited by irealms on Thu Oct 28, 2004 2:50 am, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
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.
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.
Code: Select all
header("Location: script.php");(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
?>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.
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';
}
?>- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
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.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'; } ?>
Last edited by CoderGoblin on Thu Oct 28, 2004 2:51 am, edited 1 time in total.