Sending arrays with hidden input form field

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
geethalakshmi
Forum Commoner
Posts: 31
Joined: Thu Apr 24, 2008 10:38 pm

Sending arrays with hidden input form field

Post 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
Last edited by geethalakshmi on Fri Jun 27, 2008 6:55 am, edited 1 time in total.
JacobT
Forum Commoner
Posts: 43
Joined: Tue May 13, 2008 11:07 am
Location: Los Angeles, CA

Re: What is PEAR?

Post 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/
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Sending arrays with hidden input form field

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Sending arrays with hidden input form field

Post 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 . "' />';
 
JacobT
Forum Commoner
Posts: 43
Joined: Tue May 13, 2008 11:07 am
Location: Los Angeles, CA

Re: Sending arrays with hidden input form field

Post 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 :P
Post Reply