1 回答
TA贡献1864条经验 获得超2个赞
您根本无法同时执行,因此您必须将两个标题分开,即应该是显示消息的页面的一部分。此外,没有理由(实际上是一种不好的做法)将整个HTML传递到URL中,最好使用一些ID,例如:locationrefreshrefresh
数据库.php
<?php
if(mysqli_query($link, $sql)){
header("Location: addbusiness.php?message=1");
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>
附加业务.php
<?php
if(!empty($_GET['message'])){
if($_GET['message'] == 1){
header( "refresh:5;url=index.php" );
echo "<div class='alert alert-success' role='alert' style='text-align: center; margin-bottom: 50px;'>Success.</div>";
}else{
//do something else
}
}
?>
基于这样的条件,您还将避免每次访问时刷新addbusiness.php
当然,在任何情况下,您都必须确保在调用之前没有任何HTML输出到浏览器。在两个页面中。header()
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报
