Posting an array from a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Posting an array from a form

Post 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
User avatar
Verminox
Forum Contributor
Posts: 101
Joined: Sun May 07, 2006 5:19 am

Post 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.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Code: Select all

<?php

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

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the user isn't supposed to interact with it, use sessions to pass it across.
Post Reply