Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <!-- Arquivo: calculaIdade.php -->
- <html>
- <head>
- <meta charset="utf-8"/>
- <title> Formulários </title>
- <style>
- label span { font-size: 14px; color: #666;
- padding-left:26px;
- width:125px;
- text-transform: uppercase;
- display:inline-block;
- }
- </style>
- </head>
- <body>
- <h1> Vamos calcular sua idade</h1>
- <h2>Informe seus dados:</h2>
- <?php
- $data = $_POST["dataNasc"];
- $mes = $_POST["mesNasc"];
- $ano = $_POST["anoNasc"];
- ?>
- <label for="data">Data de Nascimento:</label>
- <span><?php echo $data; ?></span>
- <br/>
- <label for="mes">Mês de Nascimento:</label>
- <span><?php echo $mes; ?></span>
- <br/>
- <label for="ano">Ano de Nascimento:</label>
- <span><?php echo $ano; ?></span>
- <br/>
- <p>
- Sua idade é: <?php
- $anoAtual = 2017; //date("Y");
- $mesAtual = 9;//date("m");
- $diaAtual = 28;//date("d");
- $idade= $anoAtual-$ano;
- if ($mes >= $mesAtual) {
- $idade=$idade-1;
- }
- if ($mesAtual == $mes) {
- if ($data < $diaAtual) {
- $idade = $idade+1;
- }
- }
- echo $idade;
- ?>
- <p/>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment