1 回答

TA貢獻1831條經驗 獲得超10個贊
發送$msg標頭
if($api_response["success"] === true) {
header("Location: https://google.com");
exit;
} else {
$msg = "Some Error Occured!";
header("Location: ".$_SERVER['HTTP_REFERER']."?msg=".$msg);
}
然后$msg像這樣讀你的
if(isset($_GET['msg'])){
print_r($_GET['msg']);
}
在你的情況下,你需要使用會話來保持私密,如下所示
if($api_response["success"] === true) {
header("Location: https://google.com");
exit;
} else {
$msg = "Some Error Occured!";
session_start();
$_SESSION['msg'] = $msg;
header("Location: ". $_SERVER['HTTP_REFERER']);
exit();
}
//and read like this
<?php
session_start();
if(isset($_SESSION['msg'])){
echo $_SESSION['msg'];
unset($_SESSION['msg']); // remove it now we have used it
}
?>
- 1 回答
- 0 關注
- 136 瀏覽
添加回答
舉報