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

Duvida sobre REcaptcha


Célio Filipe

Pergunta

Galera :rolleyes:

To com uma duvida aqui sobre o recaptcha do google.

Eu segui passo a passo o tutorial dele e não da certo na parte de verificar a respoda do usuario.

alguém pode me dar algumas dicas ou passa algum tutorial? sem ser o oficial.

Insiro a parte do formulario o captcha aparece mas quando coloco; o codigo de verificação no topo da pagina (de acordo com o tutorial do google)

a pagina não carrega.

Se caso acharem mais simples eu posto aqui o meu HTMl.

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
 <title>: Cadastro Premium ::</title>
 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
 <meta name="keywords" content="AJAX,JHR,PHP,CAPTCHA,download,PHP CAPTCHA,AJAX CAPTCHA,AJAX PHP CAPTCHA,download AJAX CAPTCHA,download AJAX PHP CAPTCHA" />
 <meta name="description" content="An AJAX CAPTCHA script, written in PHP" />

&lt;script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>

&lt;script type= "text/javascript">
var RecaptchaOptions = {
theme: 'white'
};
</script>

 &lt;script type="text/javascript" src="jquery.js"></script>
 &lt;script type="text/javascript" src="jquery.validate.js"></script>

&lt;script src="jscripts/cep.js" type="text/javascript"></script>

 <link rel="stylesheet" type="text/css" href="style.css" />
 <link href="stylecep.css" type="text/css" rel="stylesheet" />
 <style type="text/css">
  img { border: 1px solid #eee; }
  p#statusgreen { font-size: 1.2em; background-color: #fff; color: #0a0; }
  p#statusred { font-size: 1.2em; background-color: #fff; color: #a00; }
  fieldset label { display: block; }
  fieldset div#captchaimage { float: left; margin-right: 15px; }
  fieldset input#captcha { width: 25%; border: 1px solid #ddd; padding: 2px; }
  fieldset input#submit { display: block; margin: 2% 0% 0% 0%; }
  #captcha.success {
      border: 1px solid #49c24f;
    background: #bcffbf;
  }
  #captcha.error {
      border: 1px solid #c24949;
    background: #ffbcbc;
  }
 .formato {font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #000000;
}
 </style>


&lt;script>
function mascara_cpf() { 
if(document.captchaform.CPF.value.length == 3) { 
document.captchaform.CPF.value += '.'; 
} 
if(document.captchaform.CPF.value.length == 7) {
document.captchaform.CPF.value += '.'; 
}
if(document.captchaform.CPF.value.length == 11) { 
document.captchaform.CPF.value += '-'; 
}
}

function mascara_TelFixo() {
if(document.captchaform.TelFixo.value.length == 2) {
document.captchaform.TelFixo.value += ' ';
}
if(document.captchaform.TelFixo.value.length == 7) {
document.captchaform.TelFixo.value += '-';
}
}


function mascara_TelCel() {
if(document.captchaform.TelCel.value.length == 2) {
document.captchaform.TelCel.value += ' ';
}
if(document.captchaform.TelCel.value.length == 7) {
document.captchaform.TelCel.value += '-';
}
}
</script> 



&lt;script id="demo" type="text/javascript">
$(document).ready(function() {
    // validate signup form on keyup and submit
    var validator = $("#captchaform").validate({
        rules: {
            CPF: "required",
            NomeCompleto: "required",
            Curso: "required",
            RG: "required",
            Sexo: "required",
            cep: "required",
            numero: "required",
            Escolaridade: "required",
            
            //Usuario: {
                //required: true,
                //minlength: 2,
                //remote: "users.php"
            //},
            password: {
                required: true,
                minlength: 5
            },
            password_confirm: {
                required: true,
                minlength: 5,
                equalTo: "#password"
            },
            //Email: {
                //required: true,
                //email: true,
                //remote: "emails.php"
            //},
            
            dateformat: "required",
            terms: "required"
        },
        messages: {
            NomeCompleto: "Digite seu Nome Completo",
            CPF: "Você deve informar seu CPF",
            Curso: "Você deve informar qual curso irá fazer",
            RG: "Você deve informar a Identidade (RG)",
            Sexo: "Por favor, informe o sexo",
            cep: "Você deve informar o CEP",
            numero: "Informe o Número da residência",
            Escolaridade: "Você deve informar qual é a Escolaridade",
                        
            
            
            Usuario: {
                required: "Informe o Nome de Usuário do Sistema",
                minlength: jQuery.format("Digite pelo menos {6} caracteres"),
                remote: jQuery.format("{0} is already in use")
            },
            password: {
                required: "Informe uma senha",
                rangelength: jQuery.format("Digite pelo menos {6} caracteres")
            },
            password_confirm: {
                required: "Repita sua senha",
                minlength: jQuery.format("Digite pelo menos {6} caracteres"),
                equalTo: "A Confirmação de Senha não confere"
            },
            Email: {
                required: "Por favor insira um email válido",
                minlength: "Por favor insira um email válido",
                remote: jQuery.format("{0} is already in use")
            },
            terms: " "
        },
        // the errorPlacement has to take the table layout into account
        errorPlacement: function(error, element) {
            if ( element.is(":radio") )
                error.appendTo( element.parent().next().next() );
            else if ( element.is(":checkbox") )
                error.appendTo ( element.next() );                
            else
                error.appendTo( element.parent().next() );
        },
        specifying a submitHandler prevents the default submit, good for the demo
        submitHandler: function() {
        },
        // set this class to error-labels to indicate valid fields
        success: function(label) {
            // set   as text for IE
            label.html(" ").addClass("checked");
        }
    });
    
    // propose username by combining first- and lastname
    $("#username").focus(function() {
        var firstname = $("#firstname").val();
        var lastname = $("#lastname").val();
        if(firstname && lastname && !this.value) {
            this.value = firstname + "." + lastname;
        }
    });

});
</script>




</head>

<body>

<h1>CADASTRO PREMIUM</h1>

<form id="captchaform" onSubmit="return false" name="captchaform"action="index.php">

<fieldset>
<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="CPF" for="CPF">CPF:</label></td>
<td width="126"><input name="CPF" type="text" class="field" id="CPF" onkeyup="mascara_cpf()" size="20" maxlength="14" /></td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="NomeCompleto" for="NomeCompleto">Nome Completo:</label></td>
<td width="396"><input name="NomeCompleto" type="text" class="field" id="NomeCompleto" value="" size="65" />    </td>
<td width="529" class="status"></td>
</tr>
</table>
  
<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Usuario" for="Usuario">Usuário:</label></td>
<td width="186"><input name="Usuario" type="text" class="field" id="Usuario" value="" size="30" />       </td>
<td width="739" class="status"></td>
</tr>
</table>
  
<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Senha" for="password">Senha:</label></td>
<td width="126"><input name="password" type="password" class="field" id="password" size="20" maxlength="12" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="ConfirmacaoSenha" for="password_confirm">Confirme a Senha: </label></td>
<td width="126"><input name="password_confirm" type="password" class="field" id="password_confirm" size="20" maxlength="12" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Curso" for="Curso">Curso:</label></td>
<td width="349"><select name="Curso" class="field" id="Curso">
<option value="" selected="selected">..........</option>
<option value="Administração de Empresas com Ênfase em Varejo">Administração de Empresas com Ênfase em Varejo</option>
<option value="Auxiliar de Plataforma - Petróleo e Gás">Auxiliar de Plataforma - Petróleo e Gás</option>
<option value="Como Cuidar de Bebês">Como Cuidar de Bebês</option>
</select></td>
<td width="576" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="TelFixo" for="TelFixo">Telefone Fixo: </label></td>
<td width="126"><input name="TelFixo" type="text" class="field" id="TelFixo" onkeyup="mascara_TelFixo()" size="20" maxlength="12" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="TelCel" for="TelCel">Telefone Celular:</label></td>
<td width="126"><input name="TelCel" type="text" class="field" id="TelCel" onkeyup="mascara_TelCel()" size="20" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Email" for="Email">Email:</label></td>
<td width="396"><input name="Email" type="text" class="field" id="Email" value="" size="65" />    </td>
<td width="529" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="ConfirmacaoEmail" for="Email_Confirm">Confirme Email:</label></td>
<td width="396"><input name="Email_Confirm" type="text" class="field" id="Email_Confirm" value="" size="65" />    </td>
<td width="529" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="RG" for="RG">Identidade (RG):</label></td>
<td width="186"><input name="RG" type="text" class="field" id="RG" value="" size="30" />    </td>
<td width="739" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="OrgaoEmissor" for="OrgaoEmissor">Orgão Emissor:</label></td>
<td width="126"><input name="OrgaoEmissor" type="text" class="field" id="OrgaoEmissor" value="" size="20" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Sexo" for="Sexo">Sexo:</label></td>
<td width="189"><input type="radio" name="Sexo" id="radio6" value="Masculino" />
Masculino
<input type="radio" name="Sexo" id="radio7" value="Feminino" />
Feminino </td>
<td width="736" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="CEP" for="cep">CEP:</label></td>
<td width="197"><input name="cep" type="text" class="field" id="cep" size="20" maxlength="9" />
<button id="btn" onclick="return getEndereco()">Consultar</button>      </td>
<td width="728" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Endereco" for="endereco">Endereço:</label></td>
<td width="396"><input name="endereco" type="text" class="field" id="endereco" value="" size="65" />    </td>
<td width="529" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Numero" for="numero">Numero:</label></td>
<td width="126"><input name="numero" type="text" class="field" id="numero" value="" size="20" />    </td>
<td width="799" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Complemento" for="complemento">Complemento:</label></td>
<td width="186"><input name="complemento" type="text" class="field" id="complemento" value="" size="30" />    </td>
<td width="739" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Bairro" for="bairro">Bairro:</label></td>
<td width="186"><input name="bairro" type="text" class="field" id="bairro" value="" size="30" />    </td>
<td width="739" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Cidade" for="Cidade">Cidade:</label></td>
<td width="186"><input name="cidade" type="text" class="field" id="cidade" value="" size="30" />    </td>
<td width="739" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Estado" for="estado">Estado:</label></td>
<td width="65"><input name="estado" type="text" class="field" id="estado">
</td>
<td width="860" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="Escolaridade" for="Escolaridade">Escolaridade:</label></td>
<td width="654"><input name="Escolaridade" type="radio" id="radio" value="Analfabeto" />
Analfabeto
<input type="radio" name="Escolaridade" id="radio2" value="Ensino Fundamental" />
Ensino  Fundamental
<input type="radio" name="Escolaridade" id="radio3" value="Ensino Medio" />
Ensino  Médio
<input type="radio" name="Escolaridade" id="radio4" value="Superior Imcompleto" />
Superior  Incompleto
<input type="radio" name="Escolaridade" id="radio5" value="Pos Graduacao" />
Pos  Graduação </td>
<td width="271" class="status"></td>
</tr>
</table>

<table width="0" border="0" cellpadding="0">
<tr>
<td width="133" class="label"><label id="DataDoCadastro" for="DataDoCadastro">Data do Cadastro:</label></td>
<td width="96"><input name="DataDoCadastro" type="text" readonly="readonly" class="field" id="DataDoCadastro" onkeyup="mascara_data()" value="<?php echo $Data;?>" size="15" maxlength="10" />    </td>
<td width="829" class="status"></td>
</tr>
</table>

</fieldset>

<fieldset>
ANTI-FRAUDE

<?php

require_once('recaptchalib.php');

$publickey = '6Lc5mL4SAAAAAHyqeFf5HG-66vqcQxJX6HLke86T';
$privatekey = '6Lc5mL4SAAAAAMSdY0bluDpAf7DyhygWXOgkH1p_';

//resposta reCAPTCHA
$resp = null;
//código do erro reCAPTCHA
$error = null;

//verifica se a pagina já foi submetida
if ($_POST['submit']) {
 $resp = recaptcha_check_answer ($privatekey,
 $_SERVER["REMOTE_ADDR"],
 $_POST["recaptcha_challenge_field"],
 $_POST["recaptcha_response_field"]);

 if ($resp->is_valid) {


require ("conexao.php");

$Data = date("d/m/Y");

$CPF = $_GET["CPF"];
$NomeCompleto = $_GET["NomeCompleto"];
$Usuario = $_GET["Usuario"];
$Senha = $_GET["Senha"];
$ConfirmeSenha = $_GET["ConfirmeSenha"];
$Curso = $_GET["Curso"];
$TelFixo = $_GET["TelFixo"];
$TelCel = $_GET["TelCel"];
$Email = $_GET["Email"];
$ConfirmeEmail = $_GET["ConfirmeEmail"];
$RG = $_GET["RG"];
$OrgaoEmissor = $_GET["OrgaoEmissor"];
$Sexo = $_GET["Sexo"];
$CEP = $_GET["CEP"];
$Endereco = $_GET["Endereco"];
$Numero = $_["Numero"];
$Complemento = $_POST["Complemento"];
$Bairro = $_POST["Bairro"];
$Cidade = $_POST["Cidade"];
$Estado = $_POST["Estado"];
$Escolaridade = $_POST["Escolaridade"];
$DataDoCadastro = invertedata($_POST["DataDoCadastro"]);


if($NomeCompleto!="")
{

$query = "INSERT INTO cadastro_premium (NomeCompleto, Endereco, Numero, Bairro, Cidade, Complemento, Estado, TelFixo, TelCel, Email, ConfirmeEmail, CPF, RG, OrgaoEmissor, Sexo, Escolaridade, DataDoCadastro) VALUES ('$NomeCompleto','$Endereco','$Numero','$Bairro','$Cidade','$Complemento','$Estado','$TelFixo','$TelCel','$Email','$ConfirmeEmail','$CPF','$RG','$OrgaoEmissor','$Sexo','$Escolaridade','$DataDoCadastro')";

$sql=mysql_query($query);

echo "&lt;script Langua='JavaScript'>
        alert('OS DADOS FORAM CADASTRADOS COM SUCESSO!')
        </Script>";

}

?>


<?php
} else {

 $error = $resp->error; //Mensagem de erro.

 }

}
else{

echo recaptcha_get_html($publickey, $error);
}
?>
</fieldset>
<input type="submit" name="submit" id="submit" value="CONTINUAR" />

</form>

</body>

</html>
<?php
function invertedata($Data)
{
$Pos = explode("/",$Data);
$DataInvertida = $Pos[2]."-".$Pos[1]."-".$Pos[0];
return $DataInvertida;
}
?>

Ta ai o codigo :rolleyes:

Aguardo Resposta Galera vlw (y)

Link para o comentário
Compartilhar em outros sites

  • 0

Infelizmente não posso ajudar pois nunca utilizei o recaptcha, eu apenas utilizo o ValidForm Builder que já tem um desses pronto.

Talvez alguém que já tenha usado possa te ajudar...

obs: não aparece nenhuma mensagem de erro ou coisa assim?

Editado por Stoma
Link para o comentário
Compartilhar em outros sites

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,1k
    • Posts
      651,8k
×
×
  • Criar Novo...