Hey Guys,
Im trying to do something with PHP forms that has got me stumped. Here is the situation;
- Im currently retreving the total number of input fields from they user, then dynimically printing them to the user. Like this: (where the user has enterd $num_accoutns)
for ($i=1; $i <= $num_accounts; $i++){
echo "<input type=\"text\" name\"account_$i\" maxlength=\"20\"><br>";
}
- From there i post to another form, now here is the problem. For me to validate all the account_$i fields im trying to do this;
for ($i=1; $i<=$num_invoices; $i++){
$current_field = "invoice".$i; //Replicate the field name dynamically
$field_value = $POST['$current_field']; //Retreive the field value
if(ereg('[0-9]', $field_value)) //Then check to see they enterd numeric values only
//insert error checking here
}
BUT the problem i am having is $_POST['$current_field']; - i cant refer to the form field which is a vairable any ideas?? Im stumped!
Thanks
Sherif