I am working on an insertion of data from a formative php to a database (mysql), I want the code to warn me or show an error message in 'echo' in case the query variable $ Result throw an error
PHP-HTML CODE
<?php
$con=mysqli_connect ('127.0.0.1','root','','freatico') or die ('ERROR EN LA CONEXION A LA BASE DE DATOS');
$sql="INSERT INTO puntos VALUES ('".$_POST['idp']."','".$_POST['locali']."','".$_POST['ultmed']."','".$_POST['vref']."','".$_POST['altubo']."','".$_POST['sms']."')";
$resultado=mysqli_query($con,$sql) or die ('ERROR EN EL QUERY DATABASE');
if($resultado){
if( mysqli_num_rows( $resultado )<=0){
echo 'EL PUNTO QUE ACABA DE REGISTRAR YA EXISTE';
}
}
mysqli_close ($con);
?>
I thank you if you help me to reconstruct my code so that I can do what I need.