当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Can you display a success message after redirect without using a session?

问题描述:

Is it possible to show success message on another page without using $_SESSION?

Example

process.php

header('location:/thank-you.php');

$success = 'Thank you. Please come again';

exit();

thank-you.php

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

Currently it's not working. Let me know how it can be done.

网友答案:

You could do this:

process.php

header('location: /thank-you.php?mess=1');
exit();

thank-you.php

$mess = isset($_REQUEST['mess']) ? $_REQUEST['mess'] : null;
if($mess == 1) {
  echo 'Thank you. Please come again'; }

This is not optimal but should work for simple scenarios.

网友答案:

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

and

$success =$_GET['success'];
if(isset($success)) { echo $success; }
分享给朋友:
您可能感兴趣的文章:
随机阅读: