Algué sabe dizer o que tem de erra aque? <?php
$cpf=$_POST["cpf"];
$soma1=$_POST["soma1"];
$dgt1=$_POST["dgt1"];
$soma2=$_POST["soma2"];
$dgt2=$_POST["dgt2"];
$erro=$_POST["erro"];
function vCPF($cpf)
{
$n[1]=substr($cpf, 0, 1);
$n[2]=substr($cpf, 1, 1);
$n[3]=substr($cpf, 2, 1);
$n[4]=substr($cpf, 3, 1);
$n[5]=substr($cpf, 4, 1);
$n[6]=substr($cpf, 5, 1);
$n[7]=substr($cpf, 6, 1);
$n[8]=substr($cpf, 7, 1);
$n[9]=substr($cpf, 8, 1);
$n[10]=substr($cpf, 9, 1);
$n[11]=substr($cpf, 10, 1);
$soma1=($n[1]*10)+($n[2]*9)+($n[3]*8)+($n[4]*7)+($n[5]*6)+($n[6]*5)+($n[7]*4)+($n[8]*3)+($n[9]*2);
$dgt1=11-($soma1%11);
if($dgt1==10 or $dgt1==11)
{
$dgt1=0;
}
$soma2=($n[1]*11)+($n[2]*10)+($n[3]*9)+($n[4]*8)+($n[5]*7)+($n[6]*6)+($n[7]*5)+($n[8]*4)+($n[9]*3)+($dgt1*2);
$dgt2=11-($soma2%11);
if($dgt2==10 or $dgt2==11)
{
$dgt2=0;
}
if($dgt1<>$n[10] OR $dgt2<>$n[11])
{
$erro=true;
}
else
{
$erro=false;
}
return $erro;
}
//Usando a função para verificar o CPF
if(vCPF($cpf))
{
echo "Numero do CPF inválido <br>";
echo "<a href=\"LAB03.htm\">Clique aqui para corrigir o CPF</a>";
exit;
}
echo "O CPF está correto";
?>
Digito o CPF nesse formulário:
<html>
<head>
<title>Como verificar se um PDF está correto</title>
</head>
<body>
<form name="form1" method="POST" action="LAB03.php">
Digite o número do seu CPF(sem pontuação): <input type="text" name="cpf" size="20" /><br /><br />
<input type="submit" value="Enviar" />
</font>
</body>
</html> Não importa se o CPF está correto ou errado, ele sempre exibe a menssagen de que o CPF ta correto, alguém sabe o que tem errado nele?