-
-
Save xexu/c94bbfc204f96f7b2a98d9e7acc83241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "vendor/autoload.php"; | |
$secret = 'GQ3e7zjLwXUtftQJMGBbARQ85tVTkHHSx72XaBB3'; | |
if (isset($_POST["name"]) && $_POST["name"]) { | |
$gRecaptchaResponse = isset($_POST["g-recaptcha-response"])? $_POST["g-recaptcha-response"] : null; | |
$recaptcha = new \ReCaptcha\ReCaptcha($secret); | |
$resp = $recaptcha->verify($gRecaptchaResponse, $_SERVER['REMOTE_ADDR']); | |
if ($resp->isSuccess()) { | |
die("Enhorabuena, eres un humano!"); | |
} else { | |
die("beep bop!"); | |
} | |
} | |
if (isset($_POST["email"]) && $_POST["email"]) { | |
$gRecaptchaResponse = isset($_POST["g-recaptcha-response"])? $_POST["g-recaptcha-response"] : null; | |
$recaptcha = new \ReCaptcha\ReCaptcha($secret); | |
$resp = $recaptcha->verify($gRecaptchaResponse, $_SERVER['REMOTE_ADDR']); | |
if ($resp->isSuccess()) { | |
die("Enhorabuena, eres un humano!"); | |
} else { | |
die("beep bop!"); | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Ejemplo Invisible reCAPTCHA acceseo.com</title> | |
<script src='https://www.google.com/recaptcha/api.js'></script> | |
<script> | |
function onSubmit(token) { | |
document.getElementById("demo-form").submit(); | |
} | |
function onSubmitEmail(token) { | |
document.getElementById("demo-form-email").submit(); | |
} | |
</script> | |
</head> | |
<body> | |
<form id="demo-form" action="index.php" method="post"> | |
<label>Nombre <input type="text" id="name" name="name" /></label> | |
<input type="submit" class="g-recaptcha" data-sitekey="a7axuLvFzsEssDtgRYTCpfXbB5seGdRnaERUJHWS" data-callback="onSubmit"/> | |
</form> | |
<hr> | |
<form id="demo-form-email" action="index.php" method="post"> | |
<label>Email <input type="text" id="email" name="email" /></label> | |
<input type="submit" class="g-recaptcha" data-sitekey="a7axuLvFzsEssDtgRYTCpfXbB5seGdRnaERUJHWS" data-callback="onSubmitEmail"/> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment