I have the following code, which puts a chronometer in countdown and sends the form the data you have to the BD but the problem is that the users to update the web page, the timer returns after 2 minutes. There is some way for the relog to keep time. I have the login made in PHP and mysql where access to this site is for the charge is equal to or less than 3 then access the page and if not then it does not show the page.
<?php
include("../sesion.class.php");
$sesion=new sesion();
$cargo=$sesion->get("cargo");
$usuario=$sesion->get("usuario");
if ($cargo=='3') { ?>
// se escribe el contenido de la pagina web
//fin del sitio web
<?php }else{
echo "No eres Administrador y No tienes Permiso para ver esta pagina ";
echo "<a href ='../index.php' > REGRESAR </a>";
}?>
<script>
var salida = document.getElementById("tiempo"),
minutos = 2,
segundos = 0,
intervalo = setInterval(function(){
if (--segundos < 0){
segundos = 59;
minutos--;
}
salida.innerHTML = minutos + ":" + (segundos < 10 ? "0" + segundos : segundos);
if (!minutos && !segundos){
clearInterval(intervalo);
document.getElementById("test").submit();
}
}, 1000);
</script>
this is the form
<form action="accion.php" method="post" id="test">
<label id = "tiempo">02:00 </label><br>
<input type='text' name='name' >
<button type="submit" name="test" id="test" class="btn-u btn-block rounded">Siguiente >>>> </button>
</form>