note 95321 deleted from function.header by danbrown
| From: | danbrown@php.net | Date: | Sun, 27 Dec 2009 20:08:40 +0000 |
| Subject: | note 95321 deleted from function.header by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164361@lists.php.net to get a copy of this message | ||
Note Submitter: tomikaze
----
Someone may soon come to that POST data is not sent along implicitly when making a redirect by a
Location header. This can be annoying when (double) validating a form in a separate script and
redirecting back to the page containing the form if validation fails.
Though there is some woodoo for sending POST data explicitly from php, one simpler and maybe more
elegant workaround is registering POST data as session variables.
<?php
session_start();
$_SESSION = array_merge($_SESSION, $_POST);
header("Location: myform.php");
?>
Also do not forget to call session_start() at the beginning of myform.php.