pachelbel101 Posted November 10, 2006 Share Posted November 10, 2006 I've written a number of PHP applications, and in all my applications if you reload the page (or go "back" to a page), then any form fields on that page are reset to their original value. Basically I think that instead of returning to the state that page was in - as often happens on other sites - the PHP script executes again as if you typed in the URL and click "Go" instead of reloading.In an attempt to find the culprit I created a bare-bones form page - that worked perfectly on reload. Slowly I added in pieces of a page that doesn't work correctly, and still the test page worked fine. Finally, I copied everything in the "bad" page into the "good" test page, and STILL the test page worked correctly and the old page didn't.So, what do you have to do to get form data to remain when a user reloads the page, or goes "back" to a page? Or what do you NOT have to do?Thanks for your help. This has been driving me crazy for a while. Link to comment https://forums.phpfreaks.com/topic/26868-reload-is-clearing-form-data/ Share on other sites More sharing options...
Psycho Posted November 11, 2006 Share Posted November 11, 2006 You need to include this header. This will direct the browser to display the page as it is stored in the browsers cache instead of trying to reload the page from the server.header("Cache-control: private"); Link to comment https://forums.phpfreaks.com/topic/26868-reload-is-clearing-form-data/#findComment-122938 Share on other sites More sharing options...
pachelbel101 Posted November 12, 2006 Author Share Posted November 12, 2006 Ok. Will this still reload the page from the server if you visit the page directly (either type in the address or click a link) or would it use the cache in this case too? Link to comment https://forums.phpfreaks.com/topic/26868-reload-is-clearing-form-data/#findComment-123431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.