我們有時遇到判斷資料錯誤時,會使用javascript:history.go(-1);,但是如果我們有啟動session時,表單中的資料會被清掉。(如果沒有啟動,browser會記住表單的內容)
在php中使用下面的語法,就可以解決掉這個問題
1.
<?php
session_start();
header(“Cache-control:private”);
?>
2.
<?php
session_cache_limiter(‘private’);
session_start();
?>
3.此法IE Only (這個方法蠻笨的,不建議使用,因為每一個form都要做調整,上面兩個方法比較簡便)
<?php
session_start();
?>
<meta name=”save” content=”history”>
<form name=”form1″ method=”post” action=”test1.php”>
<input type=”text” name=”t1″ style=”behavior:url(#default#savehistory)”>
<input type=”submit” name=”submit” value=”Next”>
</form>
近一直在解php/apache/browsers/javascript間的多角習題,真是剪不斷理還亂。
隨機文章
- 陳水扁王八蛋關鍵字測試 (2008-09-05)
- 寫jQuery網頁,你必須要做的檢查 (2009-09-15)
- We can test a internal server with private IP by serveo. (2020-01-01)
- 華碩表示暫時沒有生產10英吋Eee PC計劃 (2007-11-20)
- 免費的Gmail越來越擋不住中文的垃圾信了 (2010-10-31)