Open source reCAPTCHA alternative
<script src="https://captcheck.netsyms.com/captcheck.min.js"></script>
Put this in your form where you want the CAPTCHA:
<div class="captcheck_container"></div>
Put this in your server-side form validation (PHP example):
$url = 'https://captcheck.netsyms.com/api.php';
$data = [
'session_id' => $_POST['captcheck_session_code'],
'answer_id' => $_POST['captcheck_selected_answer'],
'action' => "verify"
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$resp = json_decode($result, TRUE);
if (!$resp['result']) {
// Replace with error-handling code
exit("CAPTCHA did not verify:" . $resp['msg']);
} else {
// The CAPTCHA is valid.
exit("CAPTCHA verified!");
}
If you have a strict Content Security Policy, change your div to this:
<div class="captcheck_container" data-stylenonce="your nonce here"></div>
Note: by using this hosted service, you agree to these terms. If you don't like them, feel free to host Captcheck on your own server.
Popular sites should self-host as well just to be nice.