Ir para conteúdo
Fórum Script Brasil
  • 0

COMO COLOCO UM VALIDADOR DE CPF NESTA PAGINA ?


99marcovi

Pergunta

Sou novato em algumas partes do php, preciso de ajuda nesta pagina pois eu não consigo incrementar o validador, pesquisei na internet mas não achei muita coisa coerente, e principalmente me deixando com duvidas, como por exemplo, onde por o codico.

 

oque eu queria fazer na verdade, é quando clicar em cadastrar, o php verifica se esse cpf existe de acordo com o calculo que é feito, se sim ele prossegue com as outras funções, se não ele avisar que o cpf e invalido.

 

segue as paginas:

 

/////////////////////////////////////////////////////////////////////////////////////////////////////     cadastrofunc.php //////////////////////////////////////////////////////////

<?php
    require("connection.php");
    session_start();
    require("proteger.php");
    proteger4(); // proteger a pagina para somente a cozinha acessar!

        if(isset($_GET["action"]) AND $_GET["action"] == "sair") {
        session_destroy();
        header("Location: http://localhost/index.php");
    }

?>

<!DOCTYPE HTML>
<html>
<head>
        <link rel="shortcut icon" href="/imagens/favicon.ico" type="image/x-icon">
    <title> Cadastrar Funcionários </title>
    <style>
    input[type=password]{   
    border-radius:4px;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    box-shadow: 1px 1px 2px #333333;    
    -moz-box-shadow: 1px 1px 2px #333333;
    -webkit-box-shadow: 1px 1px 2px #333333;
    background: #FEFFFF; 
    border:1px solid #FEFFFF;
    width:150px
}
 
textarea{
    border: 1px solid #000000;
    background:#cccccc;
    width:150px;
    height:100px;
    border-radius:4px;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    box-shadow: 1px 1px 2px #333333;    
    -moz-box-shadow: 1px 1px 2px #333333;
    -webkit-box-shadow: 1px 1px 2px #333333;
}
 
input[type=password]:hover, textarea:hover{ 
         background: #085BF6; border:1px solid #085BF6;
}
    input[type=text]{   
    border-radius:4px;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    box-shadow: 1px 1px 2px #333333;    
    -moz-box-shadow: 1px 1px 2px #333333;
    -webkit-box-shadow: 1px 1px 2px #333333;
    background: #FEFFFF; 
    border:1px solid #FEFFFF;
    width:150px
}
 
textarea{
    border: 1px solid #000000;
    background:#cccccc;
    width:150px;
    height:100px;
    border-radius:4px;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    box-shadow: 1px 1px 2px #333333;    
    -moz-box-shadow: 1px 1px 2px #333333;
    -webkit-box-shadow: 1px 1px 2px #333333;
}
 
input[type=text]:hover, textarea:hover{ 
         background: #085BF6; border:1px solid #085BF6;
}
 
input[type=submit]{
        background:#006699;
        color:#ffffff;
}
    body{

        background-image:url(/imagens/fundo.jpg);
        background-attachment:fixed;
        background-size:100%;
        background-repeat:no-repeat;
        background-color:@000;

    }

        </style>
        <link rel="stylesheet" type="text/css" href="/css/menu.css" />
        <style type="text/css">
        .tabela {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: 10px;
        }
        </style>
        <script>
        function formatar(mascara, documento){
          var i = documento.value.length;
          var saida = mascara.substring(0,1);
          var texto = mascara.substring(i)
  
          if (texto.substring(0,1) != saida){
            documento.value += texto.substring(0,1);
          }
  
        }
        </script>
    </head>
    <div class="menu">
    <div class="center">
    <ul>
        <li style="width: 20px; font-family: Tahoma; font-size: 15px" ><a href="?action=sair">  <img src="/imagens/exit_up.png"/> </a</li>
        <li style="width: 20px; font-family: Tahoma; font-size: 15px" ><a href="http://localhost/painel/gerencia/controle_func.php">  <img src="/imagens/volt_up.png"/>  </a> </li>
        <li style="width: 20px; font-family: Tahoma; font-size: 15px" ><a href="http://localhost/painel/gerencia/in_gerencia.php">  <img src="/imagens/inicio_up.png"/>  </a> </li>
    </ul>
    </div>
    </div>
<body>
        <center> <br> <br> <br> <br> <br> <br>
    <h1> <img src="/imagens/logo.png"/> </h1>
    <form action="" method="POST">
        <input style="width: 400px; font-family: Tahoma; font-size: 25px" type="text" name="anome" placeholder="Nome Completo" /> <br />  <br />
                  <tr>
                    <td><input style="width: 400px; font-family: Tahoma; font-size: 25px" type="text" name="acpf" placeholder="CPF" maxlength="14" OnKeyPress="formatar('###.###.###-##', this)" ></td> <br> <br>

    <td width="265"><input style="width: 400px; font-family: Tahoma; font-size: 25px" type="text" name="anasc" placeholder="Data de Nascimento (xx/xx/xxxx)" maxlength="10" OnKeyPress="formatar('##/##/####', this)" ></td>
  </tr>

                 <br />  <br />

         <label style="width: 400px; color:white; font-family: Tahoma; font-size: 25px"  >
             Local de Trabalho
         </label> <br>
                <select style="width: 400px; font-family: Tahoma; font-size: 25px" name="aperma">
              <option  value="1">Entregas</option>
              <option value="2">Cozinha</option>
                <option value="3">Contato</option>
                <option value="4">Gerencia</option>
            </select> <br />  <br />
                <input style="width: 400px; font-family: Tahoma; font-size: 25px" type="text" name="amail" placeholder="Email" /> <br />  <br />
                <input style="width: 400px; font-family: Tahoma; font-size: 25px" type="password" name="asenha" placeholder="Senha" /> <br />  <br />
                <input style="width: 400px; font-family: Tahoma; font-size: 25px" type="password" name="csenha" placeholder="Confirme sua senha" /> <br />  <br />
                <input style="width: 400px; font-family: Tahoma; font-size: 25px" type="submit" value="Cadastrar" name="botao" /> 
    </form>
</center>
    </body>
</html>

 

/////////////////////////////////////////////////////////////////////////////////////////////////////     connection.php  //////////////////////////////////////////////////////////

<?php
    $user = "root";
    $serv = "localhost";
    $pass = "";
    $data = "nonnel";

    $mysqli = new mysqli($serv, $user, $pass, $data);
    if($mysqli->connect_error) {
        echo "ERRO DE CONEXÃO COM O BANCO DE DADOS";
        exit();
    } 
?>

 

/////////////////////////////////////////////////////////////////////////////////////////////////////     proteger.php  //////////////////////////////////////////////////////////

apenas limita quem pode acessar tal pagina

 

<?php
    function proteger1() {
        if($_SESSION["aperma"] !=1) {
            echo "<script> location.href='http://localhost/index.php' </script>";
        }
    }

    function proteger2() {
        if($_SESSION["aperma"] !=2) {
            echo "<script> location.href='http://localhost/index.php' </script>";
        }
    }

    function proteger3() {
        if($_SESSION["aperma"] !=3) {
            echo "<script> location.href='http://localhost/index.php' </script>";
        }
    }

    function proteger4() {
        if($_SESSION["aperma"] !=4) {
            echo "<script> location.href='http://localhost/index.php' </script>";
        }
    }
?>

 

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...