PHP Classes
elePHPant
Icontem

File: cpf.php

Recommend this page to a friend!
  Classes of Pablo Veinberg  >  PHP Validar CPF e CNPJ  >  cpf.php  >  Download  
File: cpf.php
Role: Example script
Content type: text/plain
Description: CPF Test Example
Class: PHP Validar CPF e CNPJ
Validate Brazil fiscal numbers
Author: By
Last change:
Date: 5 years ago
Size: 1,670 bytes
 

 

Contents

Class file image Download
<!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>