note 104519 added to session.examples

From: Date: Mon, 20 Jun 2011 17:12:45 +0000
Subject: note 104519 added to session.examples
Groups: php.notes 
Request: Send a blank email to php-notes+get-180794@lists.php.net to get a copy of this message
Chris, You can also use the "GET-after-submit" design pattern: # Perform your POST or GET form processing here header("Location: $next_page_url"); If the user reloads the page (either through a refresh or history navigation), it will be the $next_page_url that gets reloaded. I typically use a sequence that looks something like: # Process the form, then... App::notice("Thank you for your form submission."); $status = App::saveStatus(); header("Location: $next_page_url&status=$status"); exit(); App::notice (and App::error) are methods in a custom application object for recording responses to be presented to the user in a page template. App::saveStatus() moves all accumulated notice and error status into a time-indexed part of the session and returns the time index. When a status parameter appears in a request, my request dispatcher checks for a stored status message with the specified time index. If found, the content is moved from the session back into the application object. Thus, any form action is only performed once, and any associated response is only displayed once (the first time $next_page_url is loaded after the form is processed). ---- Server IP: 69.147.83.197 Probable Submitter: 99.114.241.185 ---- Manual Page -- http://www.php.net/manual/en/session.examples.php Edit -- https://master.php.net/note/edit/104519 Del: integrated -- https://master.php.net/note/delete/104519/integrated Del: useless -- https://master.php.net/note/delete/104519/useless Del: bad code -- https://master.php.net/note/delete/104519/bad+code Del: spam -- https://master.php.net/note/delete/104519/spam Del: non-english -- https://master.php.net/note/delete/104519/non-english Del: in docs -- https://master.php.net/note/delete/104519/in+docs Del: other reasons-- https://master.php.net/note/delete/104519 Reject -- https://master.php.net/note/reject/104519 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180794) next »