Re: Passing Arrays between pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux