Hi,

I have a CMS admin and whenever something is edited, I send a $_GET message to the url and show a little msg, something like 'product updated' or 'prices saved'.

After 3 seconds or so the message dissappears.

(Its quite similar in idea to Gmail's messages...)

The problem is when I refresh the page, the message comes up again... because its in teh URL, something that happens quite often. And as I haven't saved anything, I'd like to to refresh the page, but not give me the message.

I've created the message using a hidden iframe, which loads the message as a separate file. After 3 seconds the file reloads to a blank, white page.

Does anyone have any suggestions of a better way to acheive this?

    send the $_GET a processing page.

    it uses the php function header("Location: $nextpage");

    this basically processes the get information then forwards to another page. this could be the success/failure page.

    then if they refresh they will just refresh the result page.

    make sense?

      Thanks dougal85, I don't quite follow...

      Do you mean to send the $_GET in the iframe as a PHP header("Location: $nextpage");?

      Because the $msg is in my url, e.g.

      index.php?page=1&msg=page updated!

      if I refresh it still sends the msg via the url...

      Stewartship, I appreciate that javascript could do the same job... but how without repeating each time I refresh the page?

      Thanks for your input guys.

        Hi Yari

        You can program the javascript to have a call function that is only called when i certain part of the script has occured, i.e. the editing would trigger the javascript function, thus you could refresh page without editing and nothing would happen.

        Alternatively if you wish to use just php try using sessions, you could create a session when editing occurs, then have the script with a if isset $SESSION['edit'] then display message, once message is sent have session destroyed so the code will only run again if another editing occurs and another $SESSION variable is set.

          Thanks Stewartship, using sessions does sound like a good idea...

          cheers!

            There is no need for sessions or JavaScript

            Page1 - submits form

            Page2 - process's form but doesnt output ANY data.

            then it uses headers() to forward to...

            page 3 - displays result.

            It's the best way to process forms without users double posting etc.

            for example, they refresh and it refreshes the result

            or they press bakc to the processing page and it knows nothing it sent so it doesnt do anything but sent them forward again. or whatever u want it to do. it could send them to a blank form.

              Thanks dougal85, that makes perfect sense. Very nice too.

              Cheers

                Write a Reply...