简体   繁体   中英

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM