Skip to content

Instantly share code, notes, and snippets.

@sebastopolys
Last active November 22, 2015 16:53
Show Gist options
  • Save sebastopolys/e67d75d72cb78d2ff1ae to your computer and use it in GitHub Desktop.
Save sebastopolys/e67d75d72cb78d2ff1ae to your computer and use it in GitHub Desktop.
Control de calendario para pasar de un mes a otro..
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$actual = date("m"); //11
$ini=$_POST['ini'];
if (!isset($_POST['ms']) && !isset($_POST['ma']) && !isset($_POST['mp']))
{
echo 'el mes es:'.$actual;
}
else{
if (isset($_POST['ms']))
{
echo 'el mes sigue siendo'.$actual;
$ini=$actual;
}
elseif (isset($_POST['ma']))
{
$ini--;
echo 'el mes ahora es'. $ini;
}
elseif (isset($_POST['mp']))
{
$ini++;
echo 'el mes ahora es'. $ini;
}
else {echo 'nada';}
}
?>
<div>
<!--
Linea 37: si el formulario no se ha enviado $_POST['ini'] es 11.
Línea 39: si ya se envió, $_POST['ini'] es el nuevo valor de $ini.
-->
<form method="post" action="prueba_counter.php" id="counter" name="counter" >
<?php if(empty($_POST)){ ?>
<input type="hidden" value='<?php echo $actual; ?>' name="ini"/>
<?php } else{ ?>
<input type="hidden" value='<?php echo $ini; ?>' name="ini"/>
<?php } ?>
<table>
<tr>
<td><input type="submit" value='Anterior' id="ma" name="ma"/></td>
<td><input type="submit" value='Mes actual' id="ms" name="ms"/></td>
<td><input type="submit" value='Proximo' id="mp" name="mp"/></td>
</tr>
</table>
</form>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment