473,386 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sending an array from a form

Hello,
How do I send an array from a form to another php page?I want to bundle
up some data from form fields in an array and send them together like that.
I must be missing something?
Thanks
Mike
Jan 17 '06 #1
9 15063
d
serialize() :)

http://uk.php.net/serialize

You also might want to look at base64_encode, as that will make it less
obvious what it is (and safer for moving around).

dave

"Mike" <so*****@microsoft.com> wrote in message
news:Mv4zf.7033$8r1.4445@trndny01...
Hello,
How do I send an array from a form to another php page?I want to bundle
up some data from form fields in an array and send them together like
that. I must be missing something?
Thanks
Mike

Jan 17 '06 #2
"Mike" <so*****@microsoft.com> wrote in message
news:Mv4zf.7033$8r1.4445@trndny01...
Hello,
How do I send an array from a form to another php page?I want to bundle
up some data from form fields in an array and send them together like
that. I must be missing something?
Thanks
Mike

<html><body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="get">
<input type="text" name="myarray[]" value="you">
<input type="text" name="myarray[]" value="mean">
<input type="text" name="myarray[17]" value="like">
<input type="text" name="myarray[dog]" value="this?">
<input type="submit">
</form>
<?php print_r($_GET['myarray']); ?>
</body></html>

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jan 17 '06 #3
d
"Kimmo Laine" <sp**@outolempi.net> wrote in message
news:3g****************@reader1.news.jippii.net...
"Mike" <so*****@microsoft.com> wrote in message
news:Mv4zf.7033$8r1.4445@trndny01...
Hello,
How do I send an array from a form to another php page?I want to
bundle up some data from form fields in an array and send them together
like that. I must be missing something?
Thanks
Mike

<html><body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="get">
<input type="text" name="myarray[]" value="you">
<input type="text" name="myarray[]" value="mean">
<input type="text" name="myarray[17]" value="like">
<input type="text" name="myarray[dog]" value="this?">
<input type="submit">
</form>
<?php print_r($_GET['myarray']); ?>
</body></html>


serialize is a lot easier ;)

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)

Jan 17 '06 #4
Kimmo Laine <an*******************@gmail.com.NOSPAM.invalid>
"d" <d@example.com> kirjoitti
viestissä:Hb****************@text.news.blueyonder. co.uk...
"Kimmo Laine" <sp**@outolempi.net> wrote in message
news:3g****************@reader1.news.jippii.net...
"Mike" <so*****@microsoft.com> wrote in message
news:Mv4zf.7033$8r1.4445@trndny01...
Hello,
How do I send an array from a form to another php page?I want to
bundle up some data from form fields in an array and send them together
like that. I must be missing something?
Thanks
Mike

<html><body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="get">
<input type="text" name="myarray[]" value="you">
<input type="text" name="myarray[]" value="mean">
<input type="text" name="myarray[17]" value="like">
<input type="text" name="myarray[dog]" value="this?">
<input type="submit">
</form>
<?php print_r($_GET['myarray']); ?>
</body></html>


serialize is a lot easier ;)

Sure it is, but I understood that the data for the array would come from the
fields of the form, while using serialize, the data should already be
available at the script, serialized there and echoed to a value a form
field. Depending on what the original poster really asked, both of these
could be valid solutions. I just assumed that he wanted the values of the
array from the form fields, of course I could be wrong.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Jan 17 '06 #5
d
"Kimmo Laine" <sp**@outolempi.net> wrote in message
news:dq**********@phys-news4.kolumbus.fi...
Kimmo Laine <an*******************@gmail.com.NOSPAM.invalid>
"d" <d@example.com> kirjoitti
viestissä:Hb****************@text.news.blueyonder. co.uk...
"Kimmo Laine" <sp**@outolempi.net> wrote in message
news:3g****************@reader1.news.jippii.net...
"Mike" <so*****@microsoft.com> wrote in message
news:Mv4zf.7033$8r1.4445@trndny01...
Hello,
How do I send an array from a form to another php page?I want to
bundle up some data from form fields in an array and send them together
like that. I must be missing something?
Thanks
Mike
<html><body>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="get">
<input type="text" name="myarray[]" value="you">
<input type="text" name="myarray[]" value="mean">
<input type="text" name="myarray[17]" value="like">
<input type="text" name="myarray[dog]" value="this?">
<input type="submit">
</form>
<?php print_r($_GET['myarray']); ?>
</body></html>
serialize is a lot easier ;)

Sure it is, but I understood that the data for the array would come from
the fields of the form, while using serialize, the data should already be
available at the script, serialized there and echoed to a value a form
field. Depending on what the original poster really asked, both of these
could be valid solutions. I just assumed that he wanted the values of the
array from the form fields, of course I could be wrong.


Well noticed :) I guess his question was a bit ambiguous - your solution is
exactly what he needs if he wants to populate an array directly from a form.

Makes me wonder why people don't read the documentation ;)
--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>

Jan 17 '06 #6
I am the original poster.(Different login-google).
To Kimmo: Now I have 2 ways of doing it. How long would it have been
for me to learn both ways.
So the reply to you're comment "Makes me wonder why people don't read
the documentation ;)" (which we all see at least once in every long
post) is
I (We) do read the documentation. But:
A. Sometimes we cant find what we're looking for fast enough.If we
knew the answer we wouldnt ask.
B. Sometimes we cant find what we're looking for .
C. More often you get better advice from other people.
Thanks,
Mike

Jan 17 '06 #7
Sorry,That was to "d"

Jan 17 '06 #8
On Tue, 17 Jan 2006 11:26:36 GMT, "Mike" <so*****@microsoft.com>
wrote:
Hello,
How do I send an array from a form to another php page?I want to bundle
up some data from form fields in an array and send them together like that.
I must be missing something?
Thanks
Mike

Just my $.02 worth:

I'm doing the same thing with multiple multi-dimensional arrays that
must pass from one form to another. Advice received from this site
recommended storing the arrays in $_SESSION['array_name'] and it works
just fine.

There, you now have THREE ways to do the same thing. And I, too, DO
read the manuals, the docs, buy the book, subscribe to the mags, etc.,
and I STILL ask here because here (and other forums) provide REAL
WORLD ANSWERS that seem to work.

After all, we read these forums to learn and, if possible, to share
our knowledge and help someone else.

Bob
Jan 18 '06 #9
On Tue, 17 Jan 2006 11:26:36 +0000, Mike wrote:
Hello,
How do I send an array from a form to another php page?I want to bundle
up some data from form fields in an array and send them together like that.
I must be missing something?
Thanks
Mike


You can always implode the array ("join", for the fans of the
OTHER scripting language) and send it as a single string.

--
http://www.mgogala.com

Jan 18 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Roy G. Vervoort | last post by:
With them help of newsgroups I created a form that makes it possible to sent an email with an attachement thats on the internet.. How can i attache a file thats on the users harddrive? this...
4
by: pablo | last post by:
Dear News Groupers, I'am trying to send a php array with a hidden input field from a form to another script. The array is NOT made directly by way of <input name="arrayname" />. The array is...
1
by: Perttu Pulkkinen | last post by:
I use hit two function to stop from sending the form. First one I use to move focus to the next desired field, second one to do nothing (when there is no desired field to go). Works in IE &...
0
by: Paul Hale | last post by:
Very new to web services. Can somebody please help me out? I would like to send an array of strings from a vb.net client to a vb.net web service. I have managed to return an array from the web...
1
by: socal | last post by:
I'm a PHP programmer, but was asked to look at a problem with a mail form using ASP (which I have never used before). I was able to figure out from Googling that the error message had to do with...
0
by: Derek M | last post by:
I am sending data to a web service thru asp.net vb Connection to web service is good and the header data goes over but the subdata which is an arra is not going. I can not set the instance...
10
by: James | last post by:
Hello, as this falls under both VB and PHP I have posted this into two newsgroups (this is the first time I've done this so if it is mucked up then I'm sorry). Anyway I want to make some simple...
1
by: Taras_96 | last post by:
Hi everyone, I've downloaded the PHP code at http://www.inventory-management.org/ and am currently in the process of trying to get the code up and running. I am running PHP version 5.1.6.6, so I...
0
by: Miraj Godha | last post by:
Hi , I want to send array from java program to postgre. For oracle we can achieve it by using: ArrayDescriptor desc = ArrayDescriptor.createDescriptor("TYPE", conn); ARRAY newArray = new...
1
by: jgentes | last post by:
I know its possible, but I haven't been able to get a hold of how to send the parameter as an array or string? function updateHours(el, val) { if(el!=null && val!=null) { ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.