note 31331 modified in function.serialize by aidan
| From: | aidan@php.net | Date: | Thu, 24 Jun 2004 10:19:08 +0000 |
| Subject: | note 31331 modified in function.serialize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71577@lists.php.net to get a copy of this message | ||
Hi!
If you wanna save all the POST data and reload it again in another time... you can use this:
(Thanks for my_stripslashes() function ;-)
<?php
// saving POST
if ($REQUEST_METHOD=="POST") {
$fp = fopen("postData.txt","w");
$data = addslashes(serialize($_POST));
fwrite($fp, $data);
fclose($fp);
}
// reloading POST and passing to variables
if (file_exists("postData.txt")) {
$data = file("postData.txt");
$data = my_stripslashes($data[0]); // catches it in some message above
$postData = unserialize($data);
extract($postData, EXTR_OVERWRITE);
}
?>
Now you have all variables from old POST in your actual script.
Well useful when you have a great form very used and of course, DEPENDING of your tool.
--was--
Hi!
If you wanna save all the POST data and reload it again in another time... you can use this:
(Thanks for my_stripslashes() function ;-)
// saving POST
if ($REQUEST_METHOD=="POST") {
$fp = fopen("postData.txt","w");
$data = addslashes(serialize($_POST));
fwrite($fp, $data);
fclose($fp);
}
// reloading POST and passing to variables
if (file_exists("postData.txt")) {
$data = file("postData.txt");
$data = my_stripslashes($data[0]); // catches it in some message above
$postData = unserialize($data);
extract($postData, EXTR_OVERWRITE);
}
Now you have all variables from old POST in your actual script.
Well useful when you have a great form very used and of course, DEPENDING of your tool.
http://php.net/manual/en/function.serialize.php