Here's the goal: To convert an array to a value passed in a form input type=hidden, and then convert it back to an array at the target page.
$obj is an array, with a variable number of
values stored.
I want to pass it, the whole thing, via an input form to another page, intact.
Here's what I've got so far trying to break it down:
ONE.PHP:
<?php
$obj[name]="Ben";
$obj[number]=1;
$objpass=serialize($obj);
$objpass=addslashes($objpass);
echo "<form method=post action=two.php>
<input name=objpass type=hidden value=$objpass>
<input type=submit>
</FORM>
";
?>
And now for page two.php:
TWO.PHP:
<?php
$obj=stripslashes($objpass);
echo $obj;
$obj=array(unserialize($obj));
?>
But this doesn't work! The output of page two is:
obj🅰2:{s:4:\"name\";s:3:\"Ben\";s:6:\"number\";i:1;}aa
But the form input from one.php is:
a:2:{s:4:\"name\";s:3:\"Ben\";s:6:\"number\";i:1;}
It seems that the main difference is that "obj" at the beginning and the "aa" at the end. How do I convert this back to an array that I can use?
Thanks guys, all of you have been immensely helpful!
-Ben