1 回答
TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個(gè)贊
您根本無法同時(shí)執(zhí)行,因此您必須將兩個(gè)標(biāo)題分開,即應(yīng)該是顯示消息的頁(yè)面的一部分。此外,沒有理由(實(shí)際上是一種不好的做法)將整個(gè)HTML傳遞到URL中,最好使用一些ID,例如:locationrefreshrefresh
數(shù)據(jù)庫(kù).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);
}
?>
附加業(yè)務(wù).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
}
}
?>
基于這樣的條件,您還將避免每次訪問時(shí)刷新addbusiness.php
當(dāng)然,在任何情況下,您都必須確保在調(diào)用之前沒有任何HTML輸出到瀏覽器。在兩個(gè)頁(yè)面中。header()
- 1 回答
- 0 關(guān)注
- 102 瀏覽
添加回答
舉報(bào)
