how can i check if the user pressed “F5” (refresh?) beacuse for example if he has filled out data in a table and after i hhave aupdated he presses F5 the update will be done again! how can i find thatout and even prevent it? thnaks i nadvance peleg
@NogDogJun 06.2005 — #I don't know of anyway to trap that on the server side.
What you can do is create a hidden field in your form and set its value to a unique ID using PHP's uniqid() function. When the form-handler receives the form data, it can store that ID in a session variable, and check subsequent requests for a duplicate ID and reject it if so:
Form: [code=php] <input type=hidden name=id value="<?php echo uniqid() ?>"> [/code] Handler: [code=php] <?php session_start(); if(isset($_SESSION['id']) and $_SESSION['id'] == $_POST['id']) { echo "<p>ERROR: Transaction already processed. Please do not resubmit the formn"; echo "or refresh the page.</p>n"; } else { $_SESSION['id'] = $_POST['id']; # do your form processing here. } ?> [/code]