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 关注
- 104 浏览
添加回答
举报