wow
wow

Reputation: 553

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.

Upvotes: 2

Views: 10489

Answers (2)

Damp
Damp

Reputation: 3348

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.

Upvotes: 4

Byron Whitlock
Byron Whitlock

Reputation: 53861

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

and

$success =$_GET['success'];
if(isset($success)) { echo $success; }

Upvotes: 0

Related Questions