Reply to Re: [PHP] Passing Arrays between pages

Your name:

Reply:


Posted by Josh Whiting on 09/28/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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация