I try to apply solutions of others answers I have seen in this web but my redirect not work no way.
I have a formulary with the only mission is make a insert in a table and for that, I have 2 pages: 1 with a formulary and the other contains php code for the insert. Ok, the insertion works, but the header() function don't redirect me to the formulary again. Why?
$fecha = $_POST["fecha_marcaje"];
$hora = $_POST["hora_marcaje"];
$nombre = $_POST["nombre"];
$pin = $_POST["pin"];
$fechayhora = $fecha." ".$hora;
$con=mysqli_connect('************','************','************','************');
if (mysqli_connect_errno()) {
echo "Error de conexión con la base de datos: " . mysqli_connect_error();
}
if(empty($fecha) || empty($hora)){
echo "Debe rellenar todos los campos";
}else{
$sql="INSERT INTO `webemple_pw5`.`fichajes` (`Name`, `sTime`, `VerifyFlag`, `MachineName`, `checktype`, `sensorid`, `workcode`, `sDate`, `Pin`) VALUES ('$nombre', '$fechayhora', NULL, NULL, NULL, NULL, NULL, '$fecha', '$pin')";
}
//header("Location:". home_url('/') . "wp-content/themes/twentyfourteen/visualizar-tiempo.php?bn=$pin");
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
header("Location: /wp-content/themes/twentyfourteen/visualizar-tiempo.php?bn=$pin");
exit();