b页面的代码如下:
tieba3.php
;
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();
检查$_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
prepare("insert into reply(reid,name,content)values(:reid,:name,:content)"); $stnt->execute($_POST); echo " ";}?>现在流行 ajax,页面已经不会跳转了
自然页不会依赖浏览器的 后退 按钮
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论