Page 1 of 1
Sending arrays with hidden input form field
Posted: Fri May 16, 2008 4:43 am
by geethalakshmi
Hi
I have an array of values and i am trying to send the array values with a hidden input field from a form to another script.How can this be done?
Code:
<input type=hidden name=array value="<?php echo $arrayname;?>">
I want to post the array values in another php page.Is this possible?
regards
geetha
http://www.codingcoding.com
http://www.lkjhgfdsa.org
Re: What is PEAR?
Posted: Fri Jun 27, 2008 6:50 am
by JacobT
Please use google next time, we're not here to spoon-feed you.
"PEAR is a framework and distribution system for reusable PHP components."
http://pear.php.net/
Re: Sending arrays with hidden input form field
Posted: Fri Jun 27, 2008 8:02 am
by andym01480
Mods - what is going on? Why a reply to a different post above?
geethalakshmi - probably easiest to use a session to pass the array to the next script.
Code: Select all
session_start(); at the very top of the script before any browser output
$_SESSION['arrayname']=$arrayname; //puts the array into a an array in the session
Code: Select all
//on the next script
session_start(); //at the very top before any browser output
$arrayname=$_SESSION['arrayname']; //to retrieve
Re: Sending arrays with hidden input form field
Posted: Fri Jun 27, 2008 9:16 am
by jayshields
Or you could run a foreach, something like this:
Code: Select all
foreach($array as $a)
echo '<input type="hidden" name="array[]" value="' . $a . "' />';
Re: Sending arrays with hidden input form field
Posted: Fri Jun 27, 2008 9:43 am
by JacobT
Mods - what is going on? Why a reply to a different post above?
And it just happened to me in a way that makes me look like a jerk
