0
Hello, I’m following the google steps to create a recaptcha in the validation and login area of the system.
I am entering in the right places, of my code, the keys generated in google. However the recaptcha is not working. When I enter the password and login and do not click (mark the box) in recaptcha, the user can enter the system normally. I mean, the recaptcha is just there for embellishment.
I will post the code to see if you help me. (NOTE: I changed the keys generated in google to my system)
Thanks for your attention. Thank you!
<?php
session_start();
//CHAMANDO O ARQUIVO DE CONEXÃO COM O BANCO DE DADOS
require_once("banco/conexao/conexao-com-banco.php");
require_once("banco/atualizador/atualizador-tarefas-web.php");
require_once("banco/atualizador/corretor.php");
require_once("banco/validador-de-login/validador-login.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>T-GET</title>
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=devide-width, initial-scale=1">
<meta charset="UTF-8">
<script src="_jQuery/jquery-3.2.1.min.js"></script>
<!-- ARQUIVO JQUERY -->
<script src="https://www.google.com/recaptcha/api.js"></script>
<link href="_css-index/pagina-login/estilo-telalogin.css" rel="stylesheet">
<!-- ARQUIVO CSS DO -->
<link href="_bootstrap4.1.1/css/bootstrap.min.css" rel="stylesheet">
<!-- ARQUIVO CSS DO BOOTSTRAP -->
</head>
<body>
<!-- INTRODUÇÃO VIDEO - ANDREWS-->
<div class="container-fluid" style="background-color: #0275d8;">
<div class="row" id="row-corpo">
<!-- DIV COM O FORMULÁRIO DE LOGIN -->
<div class="col-sm-4 col-sm-offset-4 col-lg-2 col-lg-offset-5" id="titulo-sistema">
<header>
<label style="color:gold; font-family:roboto; font-size:30px">T-GET</label>
<img src="_imagens/logo-azul.png">
</header>
</div>
<div class="col-xs-8 col-xs-offset-2 col-sm-4 col-sm-offset-4 col-lg-2 col-lg-offset-5" id="formulario">
<form action="banco/validador-de-login/validador-login.php" method="post" id="formulario-login-sistema">
<div class="form-group">
<label for="login">Usuário:</label>
<input class="form-control" type="text" id="login" name="login" placeholder="Digite seu usuário" required autofocus />
</div>
<div class="form-group">
<label for="senha">Senha:</label>
<input class="form-control" type="password" id="senha" name="senha" title="A senha deve conter letras, números e caracteres especiais" placeholder="Digite sua senha" pattern="^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[@#$])[a-zA-Z0-9@#$]{8,50}$" required
/>
</div>
<div class="g-recaptcha" data-sitekey="5LeniaQUAAAAAN6OmP3gg3s96j4kl6ee6re6r56t66ky6k2y"></div>
<input class="btn btn-success" type="submit" name="enviar" value="Enviar">
</form>
<div id="mensagem">
<h5>
<?php echo $mensagem ?>
</h5>
</div>
</div>
</div>
</div>
<script src="_jquery/jquery-3.2.1.min.js"></script>
<!-- ARQUIVO JQUERY -->
</body>
<!-- FIM DO BODY -->
</html>
<!-- FIM DO HTML -->
<!-- ARQUIVO validador-login.php (que é o arquivo onde rola a validação do usuário para adentrar no sistema -->
<?php
//$usuario = $_POST["login"];
$usuario = filter_input(INPUT_POST, 'login', FILTER_SANITIZE_STRING); //Depois trocar para o tipo de filtro que o campo será [Email por exemplo]
//$senha = $_POST["senha"];
$senha = filter_input(INPUT_POST, 'senha', FILTER_SANITIZE_STRING); //Depois trocar para o tipo de filtro que o campo será [Se for aceitar caracteres, por exemplo]
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
"secret"=>"5LeniaQUer6hh14j15er65gfjh6g5gf4g5f4",
"response"=>$_POST["g-recaptcha-response"],
"remoteip"=>$_SERVER["REMOTE_ADDR"]
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$recaptcha = json_decode(curl_exec($ch), true);
curl_close($ch);
if($recaptcha["success"] === true)
{
//CONSULTA DE LOGIN DO USUÁRIO "CONSULTA NA TABELA tbl_usuarios"
$mensagem = "";
if (isset ($_POST["login"]))
{
$login = "SELECT * ";
$login .= "FROM tbl_usuarios ";
$login .= "WHERE usuario = '{$usuario}' AND senha = '{$senha}' ";
$acesso = mysqli_query($conecta, $login);
if( !$acesso )
{
die("Falha na Consulta ao Banco de Dados");
}
$informacao = mysqli_fetch_assoc($acesso);
if( empty($informacao) )
{
if(isset ($_POST["enviar"]))
{
$mensagem = "Login Sem Sucesso";
}
}
else
{
$_SESSION["user_portal"] = $informacao["codigo"];
$_SESSION["nome"] = $informacao["funcionario"];
$_SESSION["departamento-usuario"] = $informacao["departamento"];
$_SESSION["empresa-origem-usuario"] = $informacao["EMPRESA_ORIGEM"];
verificaVencidos($conecta, $informacao["funcionario"]);
atualizaDataPadrao($conecta);
corrige($conecta, $informacao["funcionario"]);
unset($informacao);
header("location:cadastrar-empresas.php");
}
}
}
else
{
$mensagem = "Falha no Recaptcha";
}
?>
System Image
Is Recaptcha an iframe? If you can’t change the CSS, then the solution would be to slightly increase the container width
– hugocsl
No, @hugocls, the problem is not with the recaptcha layout. The problem is that it is not functional.
– Gato de Schrödinger
All right, I hit my eye on the image and I already thought that this would be the rss problem. Anyway, I can’t help you :/
– hugocsl
Anyway, thank you very much!
– Gato de Schrödinger