2011-01-11 103 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; } 
相关问题