是否可以在不使用$_SESSION
的情况下在其他页面上显示成功消息?您可以在不使用会话重定向后显示成功消息吗?
例
process.php
header('location:/thank-you.php');
$success = 'Thank you. Please come again';
exit();
感谢you.php
if(isset($success)) { echo $success; }
目前它不工作。让我知道它是如何做到的。
是否可以在不使用$_SESSION
的情况下在其他页面上显示成功消息?您可以在不使用会话重定向后显示成功消息吗?
例
process.php
header('location:/thank-you.php');
$success = 'Thank you. Please come again';
exit();
感谢you.php
if(isset($success)) { echo $success; }
目前它不工作。让我知道它是如何做到的。
你可以这样做:
process.php
header('location: /thank-you.php?mess=1');
exit();
感谢you.php
$mess = isset($_REQUEST['mess']) ? $_REQUEST['mess'] : null;
if($mess == 1) {
echo 'Thank you. Please come again'; }
这不是最优的,但应该适用于简单的情况。
header('location:/thank-you.php?success=Thank+You+Please+Come+again');
和
$success =$_GET['success'];
if(isset($success)) { echo $success; }
它是可能的,但丑陋。使用会话没有什么不好或复杂的 – 2011-01-11 21:59:49
你可能会使用cookies,但使用$ _SESSION会更干净。 – 2011-01-11 22:01:40