Re: browser back-button problem
| From: | marcel.britsch | Date: | Thu, 17 Oct 2002 12:06:52 +0000 |
| Subject: | Re: browser back-button problem | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120314@lists.php.net to get a copy of this message | ||
thanks a lot for this answer, it was really helpful.
unfortunately the problem is not solved entirely:
if the browser back-button is hit, the actions are not executed twice, but
still the old data is displayed.
what I did:
I put my code in tow seperat files:
1: display the file and refert to the second file, if submitted
2: do delete, do new. here the checksum is evaluted, so these actions are
only executed if they have not been executed before. works fine. thanks.
BUT if the browser back-button is used, the browser jumps back to the the
(old) #1 files with their contents to this time, meaning you dont see the
actual contents, but older ones. moreover, if now any action is called, it
is not executed, instead the #2 refers directly back to #1 (as checksums are
not identical) and displays again. this time the actual content.
although no errors can happen anymore, I find this a little confusing for
the user.
what can be done to either force the #1 to be executed again on browser back
or show some "expired" message?
thanks in advance marcel
"Jonathan Sharp" <js-lists@sharpmedia.net> schrieb im Newsbeitrag
news:3DADB109.2060105@sharpmedia.net...
> 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
> >
> >
> >
>
>
>