Page 1 of 1

Posting an array from a form

Posted: Tue Nov 28, 2006 5:04 am
by hame22
Hi I have an array $member_details.

Is it possible to try and Post this array across using a form?

at the moment I am using:

<input type="hidden" name="member_details" value="<?php print $member_details;?>" />

and attempting to re-access it using

$member_details = $_POST['member_details'];

however this does not work, if this is not the method to achieve this I would appriciate suggestions on the right ones.

Thanks in advance

Posted: Tue Nov 28, 2006 5:26 am
by Verminox
Try using serialize() to convert the array in string form... send it accross the form... and unserialize() it in your script later to get back to array form.

Posted: Tue Nov 28, 2006 5:30 am
by bokehman

Code: Select all

<?php

foreach($member_details as $key => $value)
{
	echo "<input type='hidden' name='member_details[$key]' value='$value'>\n";
}

?>

Posted: Tue Nov 28, 2006 7:52 am
by feyd
If the user isn't supposed to interact with it, use sessions to pass it across.