<!DOCTYPE html>
 
 
<html>
 
    <head>
 
        <title>Validador de CPF</title>
 
        <meta charset="UTF-8">
 
        <meta name="viewport" content="width=device-width">
 
        <link href="./css/style.css" rel="stylesheet"/>
 
    </head>
 
    <body>
 
        <div id="content">
 
            
 
          
 
            <h2>Validar CPF</h2>
 
            <div>
 
                <form method="POST">
 
                    <label>
 
                        Ingresse o CPF (Apenas números):
 
                    </label>
 
                    <input type="text" name="cpf" maxlength="11"/>
 
                    <input type="submit" value="Validar"/>
 
                </form>
 
            </div>
 
            <?php if (!is_null($_POST) && !empty($_POST['cpf'])): ?>
 
                <div>
 
 
                    <?php
 
                    $cpf = $_POST['cpf'];
 
                    unset($_POST);
 
 
                    require_once './classes/ValidarChaveFiscal.php';
 
                    $validador = new ValidarChaveFiscal($cpf, "cpf");
 
                    if ($validador->isValido()) {
 
                        echo "<p class='valido'>O CPF {$validador->getChaveFormatada()} é válido.</p>";
 
                    } else {
 
                        echo "<p class='erro'>O CPF {$validador->getChaveFormatada()} não é válido.</p>";
 
                        foreach ($validador->getErros() as $erro) {
 
                            echo "<li class='erro'>{$erro}</li>";
 
                        }
 
                    }
 
                    ?>
 
                </div>
 
            <?php endif; ?>
 
            <p><a href="./">Voltar</a></p>
 
        </div>
 
    </body>
 
</html>
 
 |