Skip to content

Instantly share code, notes, and snippets.

@kurnias
Last active December 11, 2015 00:39
Show Gist options
  • Save kurnias/4518345 to your computer and use it in GitHub Desktop.
Save kurnias/4518345 to your computer and use it in GitHub Desktop.
<?php
// call the lib..
require_once('recaptchalib.php');
// Get a key from http://recaptcha.net/api/getkey
$publickey = "";
$privatekey = "";
# was there a reCAPTCHA response?
if ($_POST["submit"]) {
$response = recaptcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($response->is_valid) {
# Valid reCAPTCHA response here
echo "Yes, that was correct!";
}
else {
# set the error code so that we can display it
echo "Eh, That wasn't right. Try Again.";
}
}
?>
<form action="verify.php" method="post">
<?php echo recaptcha_get_html($publickey, $error); ?>
<input type="submit" value="submit" name="submit"/>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment