I'm a beginner in the forum and in php and I have a question. I have a table with id auto_increment and name is primary key. It has like me to do IF and ELSE using UPDATE and INSERT. Where, if there is name just do update, otherwise do insert?
<?php
$sql = "SELECT * FROM usuarios";
if(isset($_POST['enviar'])){
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$nome = $_POST['nome'];
$cpf = $_POST['cpf'];
$result_dados_pessoais = "INSERT INTO usuarios (nome, cpf) VALUES ('$nome', '$cpf')";
$resultado_dados_pessoais= mysqli_query($conn, $result_dados_pessoais);
//ID do usuario inserido
}
?>