【发布时间】:2016-03-15 14:19:13
【问题描述】:
我正在努力做到这一点,因此当页面重新加载时,它会使用与上一页相同的 $_GET 参数重定向我。现在我正在尝试使用 header 来实现这一点,但是当我提交表单时,变量 $id 是空白的。
HTML 表单
<form action = "." method ="post">
<input type = "text" name = "username">
<textarea name = "comments"></textarea>
<input type = "hidden" name = "action" value = "posts">
<input type = "submit" name = "submit" value = "Add Post">
</form>
重定向脚本
if ( empty( $_GET ) && !empty($_POST) ){
if($action == 'posts'){
if(!isset($_GET['thread'])){
$id = $_GET['thread'];
header('Location: ' . $_SERVER['REQUEST_URI'] .'?thread='.$id);
}
}
感谢任何回复的人!
【问题讨论】:
-
你已经发布了这个 stackoverflow.com/questions/36002265/… 可能是完全重复的。
-
我不太明白你这里的逻辑......你只想得到
$_GET['thread']中的值,如果它没有设置?