========================================================== ADDING reCAPTCHA v3 (score based) TO THE CONTACT FORM Bella Vista Farm - 15 November 2026 ========================================================== WHAT YOU HAVE recaptcha.php - both keys + the token script + the server check v3 is invisible: no checkbox, no puzzle. Google scores each visitor from 0.0 (bot) to 1.0 (human) and the form decides using that score. *** Your secret key was pasted into a chat, so treat it as exposed. After everything works: google.com/recaptcha/admin > delete this key pair > create a new one > update the two lines at the top of recaptcha.php. Also check that bellavistafarm.co.za appears in the key's domain list. *** ---------------------------------------------------------- STEP 1 - Upload recaptcha.php ---------------------------------------------------------- cPanel > File Manager > public_html > Upload > recaptcha.php ---------------------------------------------------------- STEP 2 - Add the token to the form ---------------------------------------------------------- Edit public_html/contact.php. Find: Immediately ABOVE it, add this one line: It prints a hidden field, loads Google's script, and keeps the token fresh while the visitor types. You will not see anything on the page - that is correct for v3. ---------------------------------------------------------- STEP 3 - Check the score before sending ---------------------------------------------------------- Find the part of contact.php that sends the email (look for mail( or $mail->send(), and the validation block above it). Add, just before sending: require_once __DIR__ . '/recaptcha.php'; $captcha = bv_recaptcha_check(); /* 'pass', 'fail' or 'unavailable' */ if ($captcha === 'fail') { $errors[] = 'Your message looked automated, so it was not sent. Please try again.'; } Use your own error variable name if it is not $errors - for example $error, $form_errors, or whatever contact.php already uses. Why three answers instead of true/false: 'fail' - Google says bot, message is blocked 'unavailable' - Google's API could not be reached; your enquiry is still delivered (a lost booking costs more than spam) ---------------------------------------------------------- STEP 4 - Test ---------------------------------------------------------- 1. Open https://bellavistafarm.co.za/contact.php - no visible change, that is normal for v3 2. Send a test message as a human -> it should arrive 3. To see the score in action, temporarily add this line right after the bv_recaptcha_check() call: error_log('recaptcha: ' . $captcha); then check cPanel > Metrics > Errors. Real visitors normally log 'pass'; a curl script or bot logs 'fail'. If every real message is being blocked, lower the threshold on line 15 of recaptcha.php from 0.5 to 0.4 or 0.3. ---------------------------------------------------------- NOTES ---------------------------------------------------------- - v3 tokens expire after 2 minutes. The script refreshes the token every 90 seconds and again at the moment you press Submit, so a slow typist is not punished. - Do not put the secret key in contact.php's HTML output, in a JS file, or anywhere a visitor can read it. It belongs only in recaptcha.php. - Google shows a small "protected by reCAPTCHA" badge in the bottom right corner. It cannot be removed, and it is required by Google's terms when you use v3.