By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,663 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,663 IT Pros & Developers. It's quick & easy.

Back button

P: n/a
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


Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> 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?
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.
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...


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
Jul 16 '05 #2

P: 1
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
Aug 17 '05 #3

P: 1
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!
Mar 28 '06 #4

P: n/a
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="selected" 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("Location: {$_SERVER['PHP_SELF'}"));
Sep 14 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.