Back button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Albert Ahtenberg

    Back button

    Hello,

    I have two questions.

    1. When the user presses the back button and returns to a form he filled
    the form is reseted. How do I leave there the values he inserted?

    2. When the user comes back to a page where he had a submitted POST data
    the browser keeps telling that the data has expired and asks if repost. How
    to avoid that? I tried registering all POST and GET vars as SESSION vars but
    it also has its disadvantages.. .

    Cheers,
    Albert Ahtenberg




  • Steven James Samuel Stapleton

    #2
    Re: Back button

    > 1. When the user presses the back button and returns to a form he
    filled[color=blue]
    > the form is reseted. How do I leave there the values he inserted?[/color]

    A) The browser hasn't sent any data, so you cant get it, therefore
    everything is browser dependant, and you cant do anything about it as far as
    I know (unless there is some obscure meta tag).

    B) Many browsers store the information, and if a user leave the page, by any
    method, but can return to it using 'next' and 'back', then the data may
    remain, otherwise it is almost certainly lost.

    C) If you can grab the data, and know it's the correct user, you can read it
    while outputing the page, and stash it in the 'value' and 'checked'
    attributes.
    [color=blue]
    > 2. When the user comes back to a page where he had a submitted POST[/color]
    data[color=blue]
    > the browser keeps telling that the data has expired and asks if repost.[/color]
    How[color=blue]
    > to avoid that? I tried registering all POST and GET vars as SESSION vars[/color]
    but[color=blue]
    > it also has its disadvantages.. .[/color]

    As far as I know, the page will be reformed. Any data that was given to that
    page through get/post/session/your database/files will be shown. Anything
    that user entered will be lost (if they have to resubmit the data).

    However, I'm not familiar with session usage, so I can't say for certain.

    hope this helps,
    -Jim Stapleton


    Comment

    • glgyn
      New Member
      • Aug 2005
      • 1

      #3
      Re: Back Button

      Originally posted by Albert Ahtenberg
      1. When the user presses the back button and returns to a form he filled
      the form is reseted. How do I leave there the values he inserted?
      If you're working with sessions...
      Add this line right after calling session_start() to solve the problem:
      header("Cache-control: private");
      Now, users can hit the back-button to access the form containing all the information they've inputted before.
      Font: http://br2.php.net/manual/pt_BR/func...tart.php#29798

      [COLOR=Navy]Agora em português[/COLOR]
      Se você estiver trabalhando com sessões...
      Adicione essa linha logo abaixo da chamada a session_start() para resolver o problema:
      header("Cache-control: private");
      Agora, os usuários podem clicar no botão voltar para acessar o form contendo todas informações que tenham inserido antes.
      Fonte: http://br2.php.net/manual/pt_BR/func...tart.php#29798

      Comment

      • ibme_uk
        New Member
        • Mar 2006
        • 1

        #4
        Originally posted by glgyn
        If you're working with sessions...
        Add this line right after calling session_start() to solve the problem:
        header("Cache-control: private");
        Now, users can hit the back-button to access the form containing all the information they've inputted before.
        Font: http://br2.php.net/manual/pt_BR/func...tart.php#29798

        [COLOR=Navy]Agora em português[/COLOR]
        Se você estiver trabalhando com sessões...
        Adicione essa linha logo abaixo da chamada a session_start() para resolver o problema:
        header("Cache-control: private");
        Agora, os usuários podem clicar no botão voltar para acessar o form contendo todas informações que tenham inserido antes.
        Fonte: http://br2.php.net/manual/pt_BR/func...tart.php#29798
        Signed up just to say thank you! you have just got rid of a very big headache!

        Comment

        • Tyno Gendo

          #5
          Re: Back button

          Albert Ahtenberg wrote:
          Hello,
          >
          I have two questions.
          >
          1. When the user presses the back button and returns to a form he filled
          the form is reseted. How do I leave there the values he inserted?
          I always capture the values into a session and when the form is created
          I echo the session values into the value="" section, or whatever is
          needed, different in the case of checkboxes etc., have to mark as
          selected="selec ted" etc.

          You could use normal cookies too if you don't want to start a server
          session.
          2. When the user comes back to a page where he had a submitted POST data
          the browser keeps telling that the data has expired and asks if repost. How
          to avoid that? I tried registering all POST and GET vars as SESSION vars but
          it also has its disadvantages.. .
          I usually use a header redirect back to forms when data is invalid or
          when a succesful submission is made, I use a session var 'messages' to
          hold any messages to print at the top of the form

          eg.

          $_SESSION['messages'] = 'Your submission was invalid';
          exit(header("Lo cation: {$_SERVER['PHP_SELF'}"));

          Comment

          Working...