I can't find the bug. I've written a php script that produces a form, filled with an array. The last line is a input field to add a new item to the array.
My problem is that the last entry of the array is overwritten when I add new one. Here's the code:
<?php
$array = array("a");
function printForm($array)
{
if(!isset($array)){
$array = array();
}
$out=" <form name='' action='".$_SERVER['PHP_SELF']."' method='POST'><table border='1'> <tr><th colspan='2'>Namen</th></tr>";
$out = $out. "<input type='hidden' name='posted' value='yes' />";
foreach ($array as $m) {
$out = $out . "<tr><td> </td>";
$out = $out . "<td>".$m["name"]."</td></tr>";
}
$out = $out. "<tr><td> <input type='Submit' value='add' /></td>";
$out = $out. "<td><input type='text' name='name' value='' /></td>";
$out = $out."</table></form>";
echo $out;
}
if( $_POST['name']!=""){
array_push($array, $_POST['name'] );
}
printForm($array);
?>
any ideas?
Regards Michaba