我是一个可以帮助翻译的助手。
我知道这是一个非常常见的问题,但我找不到答案。
我有一个post.php,它将提交的文章表单提交给controller.php
当它正常运行时,在控制器中执行以下操作:
header("Location: ./post?ok=1");
帖子实际上已经被插入,通过上面的线路,但是浏览器中的url似乎从未更改,并且最后没有ok参数。
我可以使用会话变量来存储成功/失败参数,但这种方法应该可以工作。
post.php:
<form action="controller" method="post">
<input name="test" value='test' type="text" />
<input type="submit" value="post" />
</form>
controller.php:
<?php
header("Location: ./post?ok=1");
?>
编辑1:
header("Refresh:1;url=http://localhost/test/post?ok=1"); //doesn't work better
编辑2:
在post.php的顶部我已经放置了以下内容:
debug("post l ".count($_POST));
debug("get l ".count($_GET));
在提交前和提交后它们会显示0。
编辑3:它已经起作用了。
被阻止的原因:
if ($success){
header("Location: ./post?ok=1");
}
header("Location: ./post");
that should be:
if ($success){
header("Location: ./post?ok=1");
} else {
header("Location: ./post");
}
感谢大家。