3
I want to enter data in my database I’m using mysqli, I need to know how to indicate inside an array a variable, here and my code I want to know if this is the correct way to do it
require 'config.php'
require 'connection.php'
$nomearquivo ="teste.html";
$nome =$_POST["nome"];
$sexo =$_POST["sexo"];
$dia =$_POST["dia"];
$mes =$_POST["mes"];
$ano =$_POST["ano"];
$abre =@fopen("dadosss.html","a+");
$ess ="nome: " .$nome. " sexo: " .$sexo." ".$dia."/".$mes."/".$ano;
$escreve =fwrite($abre, $ess );
$inserir = array(
'nome' => $nome,
'sexo' => $sexo,
'dia' => $dia,
'mes' => $mes,
'ano' => $ano,
);
$grava = DBCreate('cadastro', $inserir);
if($grava)
echo 'OK';
After sanitizing the
$_POST
you can pass it right to the function. In the question code variables are created after that they are reallocated in a new array, it doesn’t seem like much work?– rray