可能我没说清 我再发一遍 我做的这个想要的效果是这样的:有一个帖子列表页a页面 从a页面点击一个标题就会跳转到这个主题页面b页面 注意这里是跳转过去的 不是打开的一个新的标签 我在b页面里面发表回复再点击浏览器的返回按钮就可以返回到a页面 这个是我想要的效果 但是现在我做的这个有个bug 就是在b页面发表完回复后点击一次浏览器的返回按钮不能回到a页面 还是留在b页面 再点击一次才能回到a页面 如果在b页面提交两次回复 需要点击三次才能回到a页面 搞不懂为什么会这样啊
b页面的代码如下:
tieba3.php
;
html>
include "cookie.php";
?>
$pdo=new pdo("mysql:host=localhost;dbname=t1","root","");
$title=$_get['id'];
$stmt=$pdo->prepare("select id,title,content from topic where id=?");
$stmt->execute(array($title));
$res=$stmt->fetchall(pdo::fetch_assoc);
foreach($res as $v){
echo ''.$v['content'].'';
}
?>
$pdo=new pdo("mysql:host=localhost;dbname=t1","root","");
$id2=$_get['id'];
$stmt=$pdo->prepare("select id,reid,content from reply where reid=?");
$stmt->execute(array($id2));
$res1=$stmt->fetchall(pdo::fetch_assoc);
foreach($res1 as $v2){
echo $v2['content'];
}
?>
提交回复插入到数据库的页面 tieba4.php
if(isset($_post['reid'])){
$pdo=new pdo("mysql:host=localhost;dbname=t1","root","");
$stnt=$pdo->prepare("insert into reply(reid,name,content)values(:reid,:name,:content)");
$stnt->execute($_post);
header("location:http://localhost/tieba3.php?id=".$_post['reid']);
}
?>
回复讨论(解决方案)
header后写个exit():试试看。
header后写个exit():试试看。
是这样吧 试了一下 不行
header("location:http://localhost/tieba3.php?id=".$_POST['reid']);
exit();
采用 php+mysql 数据库方式运行的强大网上商店系统,执行效率高速度快,支持多语言,模板和代码分离,轻松创建属于自己的个性化用户界面 v3.5更新: 1).进一步静态化了活动商品. 2).提供了一些重要UFT-8转换文件 3).修复了除了网银在线支付其它支付显示错误的问题. 4).修改了LOGO广告管理,增加LOGO链接后主页LOGO路径错误的问题 5).修改了公告无法发布的问题,可能是打压
检查$_POST['reid']是否为空而出notice,在header前加ob_clean();看看
检查$_POST['reid']是否为空而出notice,在header前加ob_clean();看看
不是空的 都是正常的
A 点击连接 进入 B :历史列表 A
B 提交到 C :历史列表 A B
C 重定向 :历史列表 A B
所以延历史列表回到 A,需要 2 次 后退
A 点击连接 进入 B :历史列表 A
B 提交到 C :历史列表 A B
C 重定向 :历史列表 A B
所以延历史列表回到 A,需要 2 次 后退
那么怎么解决呢? 我是新手没有遇到过这样的问题
一个方案:
tieba4.php
<?phpif(isset($_POST['reid'])){ $pdo=new PDO("mysql:host=localhost;dbname=t1","root",""); $stnt=$pdo->prepare("insert into reply(reid,name,content)values(:reid,:name,:content)"); $stnt->execute($_POST); echo " <script> history.go(-1); location = 'tieba3.php?id={$_POST['reid']'; </script>";}?>现在流行 ajax,页面已经不会跳转了
自然页不会依赖浏览器的 后退 按钮









