Re: parsing values from a form post

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux