
Originally Posted by
claro
What if the values are arrays, not in single values? I put it accnum[] so that form will read it as array, (I assume I write it right) and other part of my form works well, I'm way to believe it is right.
I'm using plain javascript that adds new row of textbox.
Ah!
OK, no... 
You cannot put an array into a form field.
Code:
<?php
$someArray = Array('value1', 'value2', 'value3', 'value4');
?>
<input type="next" name="someArray" value="<?=$someArray?>" />
That there, is invalid, even if you set the name="someArray" to name="someArray[]". Doing what I just did above would do this (effectively):
Code:
<input type="text" name="someArray" value="value1" />
So it would pick up the first value in the array, or it could pick up ARRAY() or it could pick up 0. Trying to put arrays into form fields isn't something I tend to do, so the actual result I'm not sure, but it will be something like one of those.
if you wanted each item in the array to be entered into a field (say you had a list of fields):
PHP Code:
$someArray = Array('value1', 'value2', 'value3');
for each($someArray as $item)
{
echo('<input type="text" name="someArray[]" value="' . $item . '" />);
}
That would create an array called someArray in the POST, but its not an array in the field, but an array of fields sharing the same name (hook). Even in that case, you arent putting an array into the field.
So in other words, the individual form fields (the inputs) are single values NOT arrays. So lets say you have 5 fields that are all accnum, the first having 1 in it, the second 2 through to the 5th having 5.
The POST ($_POST['accnum']) however is an array in those circumstances but an array of those 5 fields not one of those fields holding an array.
A single form field cannot be an array and cannot hold an array at all.
PHP Code:
$accnum = "100";
?>
<input type="text" name="accnum" value="<?=$accnum?>" />
<?
Thats valid and collected using $accnum = $_POST['accnum'];
Understand?
Bookmarks