I added Google ReCaptcha but it does not seem to work.
I use one index.html in which i have my form and a file.php to send the form.
In my console, i am at the "integration" in the "Verify the reCAPTCHA token" section and I am stuck here. I want to use the php method but I don't understand 2 things:
- What does "require 'vendor/autoload.php';" mean in the beginning of the code?
- Where do I paste this code?
I did paste the code from "Add reCAPTCHA to your website" section in my html file but it is the integration where I am stuck.
This is my form in my index.php:
<form action="submit-form.php" method="POST" class="space-y-4" name="gtld">
<input type="text" name="company" placeholder="Company Name" required class="w-full p-3 border border-gray-300 rounded" />
<input type="text" name="contact" placeholder="Contact Person" required class="w-full p-3 border border-gray-300 rounded" />
<input type="url" name="website" placeholder="Website" required class="w-full p-3 border border-gray-300 rounded" />
<fieldset class="border p-4 rounded">
<legend class="text-lg font-medium">Services Offered</legend>
<div class="space-y-2 mt-2">
<label class="block"><input type="checkbox" name="services[]" value="Application writing and submission" /> Application writing and submission</label>
<label class="block"><input type="checkbox" name="services[]" value="Provide advice and identify resources" /> Provide advice and identify resources</label>
<label class="block"><input type="checkbox" name="services[]" value="Legal services" /> Legal services</label>
<label class="block"><input type="checkbox" name="services[]" value="Backend Registry provider" /> Backend Registry provider</label>
</div>
</fieldset>
<textarea name="about" maxlength="300" placeholder="About the Company (max 300 characters)" class="w-full p-3 border border-gray-300 rounded" required></textarea>
<button class="g-recaptcha"
data-sitekey="8LcIiKwrAAAAAPyi7EBe1oNCmVORx_SYxdLVpAtk"
data-callback='onSubmit'
data-action='submit'>
Submit
</button>
</form>
I added the first necessary Google captcha scripts for the html button
I added the second script and changed the "demo-form" to the name of my form so it matches:
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
I also added the third script to my index.html as given by Google in its interface for my project/:
<button class="g-recaptcha"
data-sitekey="6LcIiKwrAAAAAPyi7EBe1oNCmVORx_SYxdLVpAtk"
data-callback='onSubmit'
data-action='submit'>
Submit
</button>
THEN, the next step is to "Verify the reCAPTCHA token" with the various methods given by Google captcha.
I tried the REST API creating a "request.json" file and added the code suggested inside:
{
"event": {
"token": "TOKEN",
"expectedAction": "USER_ACTION",
"siteKey": "8LcIiKwrAAAAAPyi7EBe1oNCmVORx_SYxdLVpAtk",
}
}
When all this is online, I proceeded with the next step "Send an HTTP POST request with the saved JSON data to the url below."
The URL below is : https://recaptchaenterprise.googleapis.com/v1/projects/annuaire-1755692338178/assessments?key=API_KEY (I changed the API_KEY to the one I created) butwhen enter the URL in my browser, I get a "his recaptchaenterprise.googleapis.com page can’t be found" : is in the browser that I should enter this URL ?
If yes...then what do I do wrong?