I have the following code that is supposed to verify if there is a regitro in a database. The problem is that it does not verify if the registry exists.
<?php
include "../Funciones/Conexion.php";
$mysqli = inicio();
$nombre = $_POST["nombre"];
$fecha = date('Y-m-d');
$horaS = date('g:i:s');
$sql = "UPDATE chequeo
SET horaS = '$horaS'
WHERE fecha = '$fecha'";
$verificar_hora = mysqli_query($mysqli, "SELECT * FROM chequeo WHERE horaS = '$horaS'");
if (mysqli_affected_rows($verificar_hora) > 0 ){
echo '<script>jQuery(function(){swal({
title:"Error",text:"Ya Checaste tu Dia De Salida, No Puedes Volver a Checar",type:"error",confirmButtonText:"Aceptar"
},function(){location.href="../Usuario.php";});});</script>';
exit;
}
$query = mysqli_query($mysqli,$sql);
if ($query){
echo '<script>jQuery(function(){swal({
title:"Exito",text:"Has Checado Con Exito",type:"success",confirmButtonText:"Aceptar"
},function(){location.href="../Usuario.php";});});</script>';
}else{
echo '<script>jQuery(function(){swal({
title:"Error",text:"Ocurrrio Un Error Al Checar",type:"error",confirmButtonText:"Aceptar"
},function(){location.href="../Usuario.php";});});</script>';
}
?>
I hope And You Can Help Me