472,341 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

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


Jul 16 '05 #1
4 17823
> 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
glgyn
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which...
1
by: Peter D. Dunlap | last post by:
Hello, I realize that this may not be the best place to ask this question, through the application is asp.net. I also realize that questions...
4
by: Hypo | last post by:
I added a 'Back' button to my page, and wrote 'OnClick' code something like this: Response.Write("<script>history.go(-" + iDepthIndex.ToString()...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date....
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. ...
6
by: tshad | last post by:
I am trying to set up a Javascript popup box that has a way of sending back a message to asp.net on how to process some data. At the moment I am...
5
by: Tom wilson | last post by:
I'm developing an application that is a benefits enrolment website. The benefits can be of any type in any order as stored in a SQL server. On...
7
by: Sridhar | last post by:
Hi, I have a question regarding the Page_Load method and Back Button of Internet explorer. I have created a webform. In that webform I have...
5
by: ns21 | last post by:
How can the browser back button be disabled If the form is submitting information to other pages or submitting to itself or using redirections. ...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.