Hello,
I have a form ( named c_sal_ord_fm.php ) with multiple line input generated like this:
for($i=0;$i<15;$i++){
echo “
<tr>
<td><input type=’TEXT’ name=’so_dat$i’ value = ‘$so_dat’
size = ’10’ maxlength=’10’/></td>
<td><input type=’TEXT’ name=’so_num$i’ value = ‘$so_num’
size = ‘6’ maxlength=’10’/></td>
} // end of loop
I want to validate the input in the calling script ( named c_sal_ord.php )
with this:
for($i = 0; $i < 15; $i++){
$so_dat = strip_tags(trim($_POST[“so_dat$i”])); // should be $so_dat$i ???
$so_num = strip_tags(trim($
$acc_nam = strip_tags(trim($_POST[“acc_nam$i”]));
$prod = strip_tags(trim($
$price = strip_tags(trim($_POST[“price$i”]));
$qty = strip_tags(trim($
/*
*/
if(!ereg(“^[0-9]{2}––
$mess = “yes”;
$message1 = “All dates must be formated dd-mm-yyyy”;
$message2 = ” “;
require_once (“c_sal_ord_fm.php”);
exit();
} // endif
[ plus others – then update the database if everything is ok ]
} // end of loop
As you can see the validation calls the form again. The problem is that I was
trying not to loose the data that was keyed in by setting the value
in the form as ‘$so_dat’ and updating it from the form when submitted.
Trouble is this only works for one line. I really need to change the variable
name with the $i each time. Of course $so_dat$i doesn’t work. I guess
two $ signs is not allowed in one variable.
Does anyone know how I do this ?
Thanks
David.