Created
May 12, 2011 10:10
-
-
Save tanakahisateru/968281 to your computer and use it in GitHub Desktop.
Request continuation for confirmation page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Request continuation | |
* | |
* This utility provides a very short lifetime (and navigation closed) session. | |
* Confirmation page shown after user input form should hold previously poted | |
* data and passes them to the next request. Those data would live in only two | |
* requests, so they should be in request scope. | |
* It's bad idea to use cookie or _SESSION to implement for confirmation page! | |
* | |
* CONFIRMATION PAGE: | |
* <input type="hidden" | |
* name="encoded_prev_post" | |
* value="<?php echo htmlspecialchars(RequestContinuation::encode($_POST));?>" /> | |
* <input type="submit" value="commit" /> | |
* | |
* COMMIT/MODIFY ACTION: | |
* $prev_post = RequestContinuation::decode($_POST['encoded_prev_post']); | |
* | |
*/ | |
class RequestContinuation { | |
/** | |
* @param $data array | |
* @return string | |
*/ | |
public static function encode($data) { | |
return http_build_query($data); | |
} | |
/** | |
* @param $data string | |
* @return array | |
*/ | |
public static function decode($data) { | |
parse_str($data, $buf); | |
return $buf; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment