开发者

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

开发者 https://www.devze.com 2023-02-04 18:00 出处:网络
Is it possible to show success message o开发者_开发百科n another page without using $_SESSION?

Is it possible to show success message o开发者_开发百科n 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; }
0

精彩评论

暂无评论...
验证码 换一张
取 消