我有一个名为 insert_comment.php 的表单,它包含以下功能:
function died($error) { // if something is incorect, send to given url with error msg
header("Location: http://mydomain.com/post/error.php?error=" . urlencode($error));
die();
}
在代码的下方,$error_message 被发送到函数 die,然后函数 die 将用户重定向到 mydomain.com/post/error.php,我从 URL 获得错误消息:
$error = $_GET["error"];
echo 'some text '. $error .' sometext';
有没有办法使用 POST 重定向来做同样的事情?我不喜欢在 URL 中显示整个错误消息,它看起来很丑陋。