Cameron
Cameron

Reputation: 28853

PHP: Show message to user e.g. Deleted

How can I show a message when say something is deleted and it appends a query string on the end of a url when it redirects so for example: domain.com/?favor_trashed=294

and it would then show a message like:

<p>Favor has been successfully deleted</p>

Upvotes: 1

Views: 356

Answers (2)

Phil
Phil

Reputation: 164970

Have a look into the Flash Messenger design pattern, the most common implementation being the one in the Zend Framework - Zend_Controller_Action_Helper_FlashMessenger

The basic idea is

  • Pop a message onto a stack in session
  • Redirect
  • Display all messages on the stack
  • Clear the stack from session

Upvotes: 6

deceze
deceze

Reputation: 522510

<?php if (!empty($_GET['favor_trashed'])) : ?>
    <p>Favor has been successfully deleted</p>
<?php endif; ?>

Upvotes: 5

Related Questions