Perhaps I don't quite understand arrays in html and php...the following code uses arrays in html forms. I would expect to get an element in each array for each input tag. I get very odd elements in the arrays - what am I doing wrong? This does NOT seem to be affected by register_globals (on or off). PHP Version 4.2.2 Apache 2.0 Filter
php code:
<html><body>
<?
print_r($_POST);
print "<br>";
$teams = $_POST['teamID'];
$nicknames = $_POST['nickname'];
$allNames = $_POST['name'];
print_r($teams);
print "<br>";
print_r($nicknames);
print "<br>";
print_r($allNames);
print "<br>";
?>
<form method="post" name=teamForm action=<? print "\"$PHP_SELF\""; ?>>
<table border=1 id="teamTable">
<tr>
<td align=center><input type=hidden value="1" name="teamID[]"><input type=checkbox value="1" name="delete[]"></td>
<td><input type=text value="Florida" name="name[]>"</td>
<td><input type=text value="" name="nickname[]"></td>
</tr></table>
<input type=submit value="Update"></form>
</body>
</html>
Expected results:
3 arrays, each with 1 element. If the checkbox is checked, the 4th array would have one element (this array seems to work).
Array ( [0] => 1 )
Array ( [0] => null )
Array ( [0] => Florida )
What I get:
Array ( [teamID] => Array ( [0] => 1 ) [name] => Array ( [0] => Florida [1] => Florida ) [nickname] => Array ( [0] => teamID[]=1 [1] => ) )
Array ( [0] => 1 )
Array ( [0] => teamID[]=1 [1] => )
Array ( [0] => Florida [1] => Florida )
html arrays in forms
Moderator: General Moderators