4
I have a form with several fields. To get the values, I am doing 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 so:
<?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 that the form fields are not mandatory and I would like to know how to do, if the user does not fill in any field, do not register, that is, check if there are any field filled. I tried to use the Count(), but even though all 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 } }
Out of curiosity, how is your HTML? The code you put last is very strange and does not seem to be a common post. Does your form have 31 fields? Strange that they came as a numerical array, including.
– Woss