I'm using a form with checkboxes. Here is part of the code:
if(isset($_POST['send'])){
$grandezas = array('tempCheckbox', "umiCheckbox", "uvCheckbox", "ventoCheckbox", "direcaoventoCheckbox", "precipitacaoCheckbox");
$grandezasCount = 0;
$tamanhoArray = count($grandezas);
for($i = 1; $i <= $tamanhoArray; $i++){
if($_POST[$grandezas[i]])
$grandezasCount++;
echo $grandezas[i]."."; // This gives me null values.
}
echo "<br>".count($grandezas)."<br>";
echo $grandezasCount;
printf("%s", $grandezas[1]);
I have the $grandezas array with the names (already checked and they are right) of the checkboxes i used in my form. They return value 1 when checked. All the rest of the form works perfectly fine with a similar logic.
When i use:
echo "<br>".count($grandezas)."<br>";
printf("%s", $grandezas[1]);
It works right, but the echo inside the for loop keeps giving me null values.
Am i using the $_POST[$grandezas[i]] in the wrong way?