Hi there,
I'm trying to figure out how to save some <form> inputs in an array. My problem is that the number of input-fields is variable.
Here's the code
<?PHP
for($counter = 1; $counter <= $addnumber; $counter++) {
?>
<tr>
<td class="content" width="20">[<?PHP if(strlen($counter) == "1") { echo "0". $counter .""; } else { echo $counter; } ?>]</td>
<td><input type="text" value="<?PHP echo $addlink.$counter; ?>" size="30" name="addlink<?PHP echo $counter; ?>"></td>
<td><input type="text" value="<?PHP echo $adddesc.$counter; ?>" size="30" name="adddesc<?PHP echo $counter; ?>"></td>
</tr>
<?PHP
}
?>
$addnumber being a number inserted by the user. If any failure occurs (maybe an input or two are incomplete) I would like the validation-script to save the values entered in an array (which I in spite of everything have managed to figure out) and then save that array in the session, so the input-fields that have been filled out won't be lost in the process.
I have tried to get it right for some time now, but it simply won't succeed for me. I have tried something like this so far.
for($counter = 1; $counter <= $addnumber; $counter++){
$addlink_array[$counter] = $_POST['addlink'. $counter .''];
$adddesc_array[$counter] = $_POST['adddesc'. $counter .''];
}
The part where I've tried to save it in the session is left out, 'cause it simply won't waork out for me 😉
I'm hoping to some help on this. It's probably not all that complicated afterall. Thanks for you help in advance.