是否可以在不使用$_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