2011-01-11 105 views
2

是否可以在不使用$_SESSION的情況下在其他頁面上顯示成功消息?您可以在不使用會話重定向後顯示成功消息嗎?

process.php

header('location:/thank-you.php'); 
$success = 'Thank you. Please come again'; 
exit(); 

感謝you.php

if(isset($success)) { echo $success; }

目前它不工作。讓我知道它是如何做到的。

+0

它是可能的,但醜陋。使用會話沒有什麼不好或複雜的 – 2011-01-11 21:59:49

+0

你可能會使用cookies,但使用$ _SESSION會更乾淨。 – 2011-01-11 22:01:40

回答

4

你可以這樣做:

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'; } 

這不是最優的,但應該適用於簡單的情況。

0

header('location:/thank-you.php?success=Thank+You+Please+Come+again');

$success =$_GET['success']; 
if(isset($success)) { echo $success; } 
相關問題