就是类似SF的一个效果 我们在帖子列表页点击某一个标题进入到这个帖子主题里面 在主题里面提交发表完回复后再点一下浏览器的后退按钮就又退回到帖子列表页了 但我做的这个效果有个bug 就是如果不提交回复点一次就能回到帖子列表页 提交回复后需要点击两次退回按钮才能退回到帖子列表页 如果在这个帖子里面提交两次回复需要点击三次退回按钮才能回到帖子列表页 这是为什么啊?
这个就是帖子的主题页 tieba3.php
<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>
tieba4.php
<?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']);
}
?>