How to insert a variable in a database which is calculated by 3 form fields
Hello all
Im having an issue trying to insert a variable in to a database.
This variable is the math result of 3 fields of the form, a division multiplied by a number.
So far is returning always 0 so i thought you might gime me a hand here
You perform calculations and then use the results of those calculations to access $_POST variables ... it seems unlikely to me that that is really supposed to be in that way.
for example, you do:
$venzini_kinisis_1 = ($_REQUEST['15']/$_REQUEST['8']) * $_REQUEST['1'];
and then later use this:
$_POST['".$venzini_kinisis_1"']
as an argument in a function. There is no guarantee $venzini_kinisis_1 really exists as a key in $_POST
You perform calculations and then use the results of those calculations to access $_POST variables ... it seems unlikely to me that that is really supposed to be in that way.
for example, you do:
$venzini_kinisis_1 = ($_REQUEST['15']/$_REQUEST['8']) * $_REQUEST['1'];
and then later use this:
$_POST['".$venzini_kinisis_1"']
as an argument in a function. There is no guarantee $venzini_kinisis_1 really exists as a key in $_POST
So how i should suppose to do it to be sure it exists as a key cause it supposed that exists.The form has already values in it ,numerical i mean.
$venzini_kinisis_1 = ($_REQUEST['15']/$_REQUEST['8']) * $_REQUEST['1'];
// check the formula and result:
echo $venzini_kinisis_1." = (".$_REQUEST['15']."/".$_REQUEST['8'].") * ".$_REQUEST['1']."<br>\n";
// check if it exists:
if (array_key_exists($venzini_kinisis_1, $_POST))
{
echo $venzini_kinisis_1." exists in POST<br>\n";
}
else
{
echo $venzini_kinisis_1." does not exist in POST, which only contains these keys: ".implode(",", array_keys($_POST))."<br>\n";
}
Bookmarks