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 开发者_JAVA百科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; ?>
精彩评论