I have a form with several fields. To get the values, I'm doing it this way (I put only the first 4):
<?php
$dados[0] = $_POST["TipoSanguineo"];
$dados[1] = $_POST["PlanoSaude"];
$dados[2] = $_POST["CalendarioVacinal"];
$dados[3] = $_POST["NomeContato"];
$dados[4] = $_POST["FoneContato"];
$metodos->cadastrarFichaMedica(array($dados));
?>
To redeem the values, I do this:
<?php
...
public function cadastrarFichaMedica($dados){
for($i = 0; $i < count($dados); $i++){
$tipoSanguineo = $dados[$i][0];
$planoSaude = $dados[$i][1];
$calendarioVacinal = $dados[$i][2];
$nomeContato = $dados[$i][3];
$telefone = $dados[$i][4];
}
mysqli_query($this->conexao,"INSERT....");
}
Only the form fields are not mandatory and I would like to know how I can do that, in case the user does not fill in any fields, do not register, that is, check if there are any fields filled out. I tried to use the count () , but even though all the fields are empty, it always returns me value 1. See:
array(1) { [0]=> array(31) { [0]=> NULL [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" [5]=> string(0) "" [6]=> string(0) "" [7]=> string(0) "" [8]=> NULL [9]=> NULL [10]=> string(0) "" [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL } }