473,385 Members | 1,813 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,385 software developers and data experts.

sending array with POST from a hidden input form field?

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 made by normal php code and then
submitted between form-tags as
echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;

I can see that the receiving script receives the array but it counts only 1
item and not the presumed amount.

Can this be done?
And how should it be done then?

TIA,

pablo

Jul 17 '05 #1
4 25536

"pablo" <pa****@exeit.removethis.demon.nl> wrote in message
news:10*************@corp.supernews.com...
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 made by normal php code and then
submitted between form-tags as
echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;

I can see that the receiving script receives the array but it counts only 1 item and not the presumed amount.

Can this be done?
And how should it be done then?

TIA,

pablo

http://ie.php.net/manual/en/function.serialize.php
Turn the array into a string and submit that

This can then be turned back into an array with
http://ie.php.net/manual/en/function.unserialize.php

Jul 17 '05 #2
pablo wrote:
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 made by normal php code and then
submitted between form-tags as
echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;
Maybe this works (not tested)

echo "<input type='hidden' name=\"arrayname\" value=\"",
urlencode(serialize($arrayname)), "\" />" ;

I can see that the receiving script receives the array but it counts only 1
item and not the presumed amount.
and the receiving script does

$array = unserialize($_POST['arrayname']);

Can this be done?
And how should it be done then?


Remember that the user can change the hidden input field.
Perhaps it would be better to pass the array in a session variable.
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3
Pedro's method is quite a good way. But if you would really want it to
be safe (like if you are transferring secret US government data :P), you
could try this,

1. Generate a random string (e.g. 19235jdsnld3235).
2. Serialize the array you are transferring and store it in a file with
the filename generated using the random string.
OR
2. Serialize the array you are transferring and store it in a record in
a database with another field storing the random string (as an index).
3. <input type="hidden" name="arraydata" value="19235jdsnld3235">
4. On the new page, just use the string to read the correct datafile or
record and Tada! you did it. ;).

This method is relatively safe as well as it will be difficult to guess
another random number. However, take good care when you store the file,
make sure you keep it in another directory or in one which is not within
the webserver root therefore increasing security.

I hope it helps :D.

ccjx

Pedro Graca wrote:
pablo wrote:
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 made by normal php code and then
submitted between form-tags as
echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;

Maybe this works (not tested)

echo "<input type='hidden' name=\"arrayname\" value=\"",
urlencode(serialize($arrayname)), "\" />" ;
I can see that the receiving script receives the array but it counts only 1
item and not the presumed amount.

and the receiving script does

$array = unserialize($_POST['arrayname']);
Can this be done?
And how should it be done then?

Remember that the user can change the hidden input field.
Perhaps it would be better to pass the array in a session variable.

Jul 17 '05 #4

"pablo" <pa****@exeit.removethis.demon.nl> wrote in message
news:10*************@corp.supernews.com...
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 made by normal php code and then
submitted between form-tags as
echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;

I can see that the receiving script receives the array but it counts only 1 item and not the presumed amount.

Can this be done?
And how should it be done then?

TIA,

pablo


And now I thank you for your quick response.

I am going to try the suggested solutions in the coming week.

THX

pablo
Jul 17 '05 #5

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

Similar topics

2
by: Roderik | last post by:
Hi, I have an array in javascript of which the contents are manipulated by the user. When he is done, he calls a function to reload the page. Then conclusion depending on the input should be...
2
by: Kingdom | last post by:
I have a SelectBoxes.asp page that is working with multiple selection dropdown boxes to extract data and total the selection prices. Tom & Bob were kind enough to give me a big help getting this...
4
by: WC Justice | last post by:
I have an ASP form that uses a recordset to build a table, with one of the columns containing a checkbox. Upon posting, the ASP code of the Post-To page uses the "For i = 1 to...
2
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
4
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of...
8
by: siol | last post by:
Hy! I have htmleditor (from the microsoft's samples page) embeded into my asp.net page. Editor generates some html code inside <div id="oDiv"></div> tags. And what I would like to do is return...
0
by: existatus | last post by:
In a form there are entries like this: <input type="text" name="first_name" size="24" /> <input type="text" name="last_name" size="24" /> <input type="hidden" name="must_have" value="12345" />...
2
by: Mike | last post by:
Hello, I am trying to pass a js array ,Round1, to a form and send it. I can get it to work with serialized values but I want to send the data as an array. The arrays are filled with data. I am...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.