Posted by Josh Whiting on 09/25/58 11:11
> >Please can someone tell me how you pass arrays between PHP pages.
>
> $var = serialize($testArray);
> echo "<INPUT NAME = \"kcompany[]\" TYPE = \"hidden\" VALUE=\"$var\">";
>
> Then unserialize the variable on the receiving page.
To this you might also add an MD5 hash to check for authenticity,
depending on what you're doing with that incoming data that you're
unserializing (consider an client who sends you a serialized array that
you didn't intend). You'll also want to encode the serialized data with
htmlentities:
$serialized = serialize($testArray);
$hash = md5($serialized . "my secret phrase");
echo '<input type="hidden" name="serialized" value="'.htmlentities($serialized).'">';
echo '<input type="hidden" name="hash" value="'.$hash.'">';
then on the receiving end:
if ($_POST['hash'] != md5($_POST['serialized'] . "my secret phrase") {
// the hash doesn't match up, consider the data unusable
} else{
$testArray = unserialize($_POST['serialized']);
}
HTH
/jw
Navigation:
[Reply to this message]
|