我这个代码为什么提交回复后点击退回键不能回到帖子列表页?

php中文网
发布: 2016-06-06 20:17:47
原创
1649人浏览过

就是类似sf的一个效果 我们在帖子列表页点击某一个标题进入到这个帖子主题里面 在主题里面提交发表完回复后再点一下浏览器的后退按钮就又退回到帖子列表页了 但我做的这个效果有个bug 就是如果不提交回复点一次就能回到帖子列表页 提交回复后需要点击两次退回按钮才能退回到帖子列表页 如果在这个帖子里面提交两次回复需要点击三次退回按钮才能回到帖子列表页 这是为什么啊?

影像之匠PixPretty
影像之匠PixPretty

商业级AI人像后期软件,专注于人像精修,色彩调节及批量图片编辑,支持Windows、Mac多平台使用。适用于写真、婚纱、旅拍、外景等批量修图场景。

影像之匠PixPretty 299
查看详情 影像之匠PixPretty

这个就是帖子的主题页 tieba3.php

<code><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />;
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
    #top{position:relative;width: 1350px;height: 50px;border: 1px solid black;}
    #main{position: relative;margin: 0 auto;width: 900px;height: 600px;border: 1px solid black;}
    li{list-style: none;display: block;float: left;width: }
    #reply{position: absolute;bottom: 20px;width: 700px;height: 200px;border: 1px solid black;}
    </style>
</head>
<body>
<div id="top">
    <?php
include "cookie.php";
?>
</div>
<div id="main">
  <div id="title">
  <?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 '<font size="5" face="arial">'.$v['content'].'</font>';
    }
  ?>
  <?php
   $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'];
     }
   ?>
  </div>
  <div id="reply" >
    <form  method="POST" action="tieba4.php">

     <input type="text" name="reid" value="<?php echo $_GET['id']; ?>">
     <input type="text" name="name" value="<?php echo $_COOKIE['username']  ?>" >
      <textarea id="title" name="content"></textarea>
      <button type="submit">提交</button>
  </form>
  </div>
</div>
</body>
</html>
</code>
登录后复制

tieba4.php

<code><?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']);
}
?></code>
登录后复制

回复内容:

就是类似sf的一个效果 我们在帖子列表页点击某一个标题进入到这个帖子主题里面 在主题里面提交发表完回复后再点一下浏览器的后退按钮就又退回到帖子列表页了 但我做的这个效果有个bug 就是如果不提交回复点一次就能回到帖子列表页 提交回复后需要点击两次退回按钮才能退回到帖子列表页 如果在这个帖子里面提交两次回复需要点击三次退回按钮才能回到帖子列表页 这是为什么啊?

这个就是帖子的主题页 tieba3.php

<code><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />;
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
    #top{position:relative;width: 1350px;height: 50px;border: 1px solid black;}
    #main{position: relative;margin: 0 auto;width: 900px;height: 600px;border: 1px solid black;}
    li{list-style: none;display: block;float: left;width: }
    #reply{position: absolute;bottom: 20px;width: 700px;height: 200px;border: 1px solid black;}
    </style>
</head>
<body>
<div id="top">
    <?php
include "cookie.php";
?>
</div>
<div id="main">
  <div id="title">
  <?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 '<font size="5" face="arial">'.$v['content'].'</font>';
    }
  ?>
  <?php
   $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'];
     }
   ?>
  </div>
  <div id="reply" >
    <form  method="POST" action="tieba4.php">

     <input type="text" name="reid" value="<?php echo $_GET['id']; ?>">
     <input type="text" name="name" value="<?php echo $_COOKIE['username']  ?>" >
      <textarea id="title" name="content"></textarea>
      <button type="submit">提交</button>
  </form>
  </div>
</div>
</body>
</html>
</code>
登录后复制

tieba4.php

<code><?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']);
}
?></code>
登录后复制
相关标签:
php
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号