Good people try to help me here on this
Part html
<form method="post" id="formulario" action="dados.php">
<p><label>Nome</label><input type="text" class="nome" name="nome" size="60" /></p>
<div id="telefone">
<p><label>Telefone</label><input type="text" class="fone" name="fone[]" size="15" /><span class="adicionar">Adicionar telefone</span></p>
</div>
<p><input type="submit" value="Enviar" id="btEnviar" name="btEnviar" />
</form>
Part php
<?php
$ligacao = mysqli_connect("localhost", "root", "", "teste");
if (mysqli_connect_errno()) {
echo "Erro na liga??o MySQL: " . mysqli_connect_error();
}
$nome=$_POST["nome"];
foreach($_POST['fone'] as $fone)
{
$inf = "select nome, tel from teste where nome = '".$nome."'";
$res=mysqli_query($ligacao,$inf);
while( ($registo = mysqli_fetch_assoc($res)) !=null)
{
$infoNome=$registo["nome"];
$infoTel=$registo["tel"];
echo $infoNome;
echo $infoTel;
}
if ($infoTel==$fone){
}
else{
$sql = "insert into teste (nome, tel) values ('$nome' ,'$fone')";
$resultado = mysqli_query($ligacao,$sql);
}
}
?>
What I want to do is that in the php part when analyzing all the numbers of mobile phone that the person introduces it will compare and if it already exists in the database does not let add again
To be easier to visualize if I entered these numbers I wanted to only enter 345, 234 and 123 once, but that is not what is happening and I can not understand why