页首加入验证文件后,go(-1)出现问题
在页首回入
<? include (../verify.php) ?>
...
<form METHOD="POST" ACTION="addmsg.php">
..
</form>
在addmsg.php中
输入有错时 document.location="javascript:history.go(-1)";
但是,当返回上个页面时,表单里原来输入的数据全没了!这是为什么呢?如何解决?请赐教!
PS.我如果把<? include (../verify.php) ?> 不要掉,返回时就正常了
问题点数:20、回复次数:8Top
1 楼tvhero(改学VB中...)回复于 2003-09-04 05:33:24 得分 0
因为你验证的时候把数据给提交了。你不用go(-1),改用response.redirect(XXX.asp?data=thedata),这样就可以在提交时先把数据保存下来,redirect时再把数据写回去。因为我原来用的是asp,所以不能给你php代码,反正大概方法是这样的。我原来就是这么做的。Top
2 楼xuzuning(唠叨)回复于 2003-09-04 09:31:43 得分 15
因为verify.php中起用了session
你可在verify.php中加入session_cache_limiter('private');或session_cache_limiter('public');
如:
<?php
session_cache_limiter('private');
session_start();
...
Top
3 楼bonniewater(陪你去看海)回复于 2003-09-04 09:32:30 得分 0
你帮你的表单的值用session保存起来吧Top
4 楼bonson(bonson)回复于 2003-09-04 12:10:47 得分 0
非常感谢 xuzuning(唠叨)
问题已得到解决!
但你能否跟我说说设成private模式跟设成public模式具体有什么区别吧?
在我问的这个问题上,设成哪种模式都行,但我想知道在其他方面,这两者有什么区别吗?Top
5 楼DFlyingchen(弱水三千)回复于 2003-09-04 12:30:07 得分 5
session_cache_limiter
(PHP 4 >= 4.0.3)
session_cache_limiter -- Get and/or set the current cache limiter
Description
string session_cache_limiter ( [string cache_limiter])
session_cache_limiter() returns the name of the current cache limiter. If cache_limiter is specified, the name of the current cache limiter is changed to the new value.
The cache limiter defines which cache control HTTP headers are sent to the client. These headers determine the rules by which the page content may be cached by the client and intermediate proxies. Setting the cache limiter to nocache disallows any client/proxy caching. A value of public permits caching by proxies and the client, whereas private disallows caching by proxies and permits the client to cache the contents.
In private mode, the Expire header sent to the client may cause confusion for some browsers, including Mozilla. You can avoid this problem by using private_no_expire mode. The expire header is never sent to the client in this mode.
注: private_no_expire was added in PHP 4.2.0.
The cache limiter is reset to the default value stored in session.cache_limiter at request startup time. Thus, you need to call session_cache_limiter() for every request (and before session_start() is called).
例子 1. session_cache_limiter() example
<?php
/* set the cache limiter to 'private' */
session_cache_limiter('private');
$cache_limiter = session_cache_limiter();
echo "The cache limiter is now set to $cache_limiter<p>";
?>
Top
6 楼bonson(bonson)回复于 2003-09-04 12:58:27 得分 0
不好意思,又有问题了
在verify.php中加了session_cache_limiter('private')后
所有包含verify.php的页面返回本页时全都不会刷新!
如:在一个添加页面,我添加了某一信息,重返回添加页面,显示的还是旧的页面
要手动刷新才能反映数据库的最新情况Top
7 楼nullfox(我把青春毁给你)回复于 2003-09-04 13:00:07 得分 0
及时雨。我也遇到了这样的问题,真谢谢各位。Top
8 楼bonson(bonson)回复于 2003-09-04 13:20:26 得分 0
我现在的解决方法是
在verify.php中不加入session_cache_limiter('private')
在需要设置session_cache_limiter('private')的页面再加上
问题都能解决了!
但我仍期待着高手提出更好的解决方法Top




