Take an md5 of the entire file contents and store that in your form that get's displayed. Then test if it matches the file when you go to make the changes. Every time you change the file the md5 will change. See below...
-js Sample script: <? $file = file('/your/text/file.txt'); if ( $_POST['doSomething'] ) { // Make sure it's the same file: if ( md5( implode('', $theFile) ) == $_POST['checksum'] ) { // Code to change the file (add/delete etc) } else { echo "File has been changed, aborting modifications."; } } else { // Just show the file ?> <form...> <input type="hidden" name="checksum" value="<?=md5( implode('', $theFile))?>"> <input type="submit" name="doSomething" value="Do something"> </form> <? } ?> marcel wrote: > hi there > I am kind of a newbie to php > so probably I am doing it all the wrong way - if - please tell me > > ok heres my problem: > the script: > I have a user-group-administration script (php4), that loads data from > a textfile and then eables the admin to delete or create new user-passwords. > the script retreives the text data from the text-file and displays the > entrys. > to every entry there is a delete-button, that sends the number of the entry. > and there are formfields and a new-button that sends the new data. > the script that is called is the same script as the one that does the > displaying, > e.g. depending on the sent variables the script delets or creates an entry > then displays the new data. > > the problem: > if someone uses the back-button of his browser, the data is transferred > again ( at > the moment I do it with POST out of the form), and the actions are executed > again. > e.g. when the user created a new entry, verytime he hits the back-button > will create > a new - similar - entry. > > How can I prevent this? > I saw several forms, that displayed this: "form is expired" thing, if you > used the back-button (?). > > > thanks a lot > marcel > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php