Re: parsing values from a form post
| From: | trlists at clayst dot com | Date: | Sat, 09 Apr 2005 01:13:14 +0000 |
| Subject: | Re: parsing values from a form post | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212687@lists.php.net to get a copy of this message | ||
On 8 Apr 2005 Chris Bruce wrote:
> I need to be able to break out the tax, amount and type that were
> entered on each line of a form and then apply calculations and do
> database inserts on each. As you can see what I need is in sets of
> three denoted by the integer at the end (tax0, amount0, type0, tax1
> etc.)
>
> I can't figure out how to separate these variables and values so that I
> can do what I need to do.
The other suggestion is a good one but if you want to do it with the
variables as you named them you can also use something like this:
for ($i = 0; $i < $maxlines; $i++) {
$tax = $_POST['tax' . $i];
$amount = $_POST['amount' . $i];
$type = $_POST['type' . $i];
.....
}
There is more one should usually do here, for security -- anything
coming in via _POST should be processed through functions designed to
remove malicious data. For example, an approach something like this:
$value = strip_tags((substr(trim($_POST[$fldname]), 0, MAX_LEN));
--
Tom