News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP in Action Blog:
Flash messages
June 02, 2008 @ 07:56:48

On the PHP in Action blog Dagfinn Reiersol shares a method to send messages across a POST request that's followed by a redirect (versus a simple GET where it can be in the URL).

When processing a GET request, you can display whatever messages you want. The most simplistic way is to echo them directly; or if just slightly more sophisticated, set it in the template that's about to become the web page. When processing a POST request that is to be followed by a redirect, you can't do that. The response (redirect) sent back to the browser does not have any text or HTML content.

He points out two different ways to handle the problem - either manually append the message to the URL you're redirecting to or (a bit better method) store it in a session variable and remove it once its done. Several frameworks call this a "flash message". He gives examples of how to set this in two popular frameworks - Zend Framework and CakePHP.

0 comments voice your opinion now!
flash message framework zendframework cakephp post message get


blog comments powered by Disqus

Similar Posts

James Fuller's Blog: Adding a Session Flash Message to your site in Lithium PHP

KillerPHP.com: Zend Framework: Using View Helpers to Build Rich, Scalable, Controls

Leonid Mamchenkov's Blog: Unit tests with CakePHP

AjaxRay.com: The first Kohana book : Kohana 3.0 Beginnerís Guide

Site News: Blast from the Past - One Year Ago in PHP


Community Events











Don't see your event here?
Let us know!


introduction security symfony2 performance release database overview application install framework facebook language opinion hack podcast hhvm composer package component unittest

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework