Verify Registration When Making an UPDATE PHP

0

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

    
asked by iBokii 03.08.2017 в 19:06
source

1 answer

0

Hello iBokii, verify what type of data the field hours have in your database, and if it is equal to the format you send:

  

$ horaS = date ('g: i: s');

in your database must have the same format, otherwise you will not find a record.

    
answered by 03.08.2017 в 19:12