Hi all, i start my php page with session_start(); I have a form using 'POST' and send the page to another page. But when i click back button, all the data i have entered before all lost. I tried to change the 'POST' to 'GET', but the result still the same, it still give me the empty fields when i click the back button. Anyone please help. Thanks in advance.
This is a matter of your browser caching, the content you get with back button is cached by the browser and is not fresh. Note also the alert message your browser sends to you after clicking the back button (this is the behavior of the default PHP headers). I'm using this headers to get rid of this message and to enable browser caching: header("Expires: Sat, 01 Jan 2000 00:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: post-check=0, pre-check=0",false); session_cache_limiter("must-revalidate"); PHP: Put this headers at the beginning of every page you want to be cached, it works good for me.
post-check: -Defines an interval in seconds after which an entity must be checked for freshness. The check may happen after the user is shown the resource but ensures that on the next roundtrip the cached copy will be up-to-date. -pre-check: Defines an interval in seconds after which an entity must be checked for freshness prior to showing the user the resource. source: http://msdn2.microsoft.com/en-us/library/ms533020(VS.85).aspx