Home  >  Article  >  Backend Development  >  在帖子里面发表回复以后 点击一下返回后回不到帖子列表页是怎么回事?

在帖子里面发表回复以后 点击一下返回后回不到帖子列表页是怎么回事?

WBOY
WBOYOriginal
2016-06-23 13:16:08891browse

我做的一个贴吧的效果  在帖子内容页点击返回可以直接返回到帖子列表页   但是如果提交回复内容后点返回却回不到帖子列表页 需要再点一次才能回去  如果提交两次回复需要按三次返回才能回到帖子列表页  提交回复次数越多需要按返回次数越多 这是怎么回事呢?


回复讨论(解决方案)

没看到代码,不好说

没看到代码,不好说


就是前几天一直问的那个代码?

如果你是用form表单,提交后相当于进入一个新页面了,点一次返回还是原来的页面
改成ajax异步提交就能达到你想要的效果了

那么多帖子,哪个知道谁对谁

那么多帖子,哪个知道谁对谁


就是下面的代码   这个是帖子主页  就是在这个页面提交内容后 点击一次回不到帖子列表页 

tieba3.php
;
nbsp;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("location:http://localhost/ tieba3.php?id=".$_POST['reid']);
而 tieba3.php 显然是内容页而不是列表页

header("location:http://localhost/ tieba3.php?id=".$_POST['reid']);
而 tieba3.php 显然是内容页而不是列表页



对啊  这只是一个插入到数据库的页面  回复提交到当前页面 提交后并且显示出来   就是这么一个页面  比如我发表回复以后想返回到帖子列表页面  点击一次后退按钮却回不到帖子列表页面

你把 tieba3.php 改成列表页的程序文件不就行了?

你把 tieba3.php 改成列表页的程序文件不就行了?


那样效果就变了啊

如果你是用form表单,提交后相当于进入一个新页面了,点一次返回还是原来的页面
改成ajax异步提交就能达到你想要的效果了


 
我不懂异步提交啊  所以不懂它是怎么实现的 不是知道是不是我想要的效果

3楼的人已经回答你了,如果你点的是浏览器的返回当然退回到上一次的页面——就是你提交之前的页面。如果你点击的是自己写的返回按钮,那就是那个返回按钮的跳转链接不对

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:好久没来,发点感慨。Next article:很简单的php问题