Google reCAPTCHA Integration (I'm Not a Robot Checkbox)

WHAT IS RECAPTCHA?
reCAPTCHA is a bot filtering tool developed by google to protect your website from fraud and abuse.

reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to prevent malware from engaging in abusive activities on your website. Meanwhile, legitimate users will be able to login, shop, view pages or create accounts, and fake users will be blocked.

If we summarize the process steps in general.

1. Register to google reCAPTCHA page.
2. Forwarding the request to the reCAPTCHA service.
Processing the returned value from the 3.reCAPTCHA service.

STEP 1

Register to google recaptcha service via the link below and keep the codes given to you. We will explain its usage in detail below.
https://www.google.com/recaptcha/admin/create

Fields to be filled

Label: Name you will give the application (any name)

reCAPTCHA type: s2, s3 (In this article I will talk about the "I am not a robot" checkbox in s2 type) integration.

Domain Names: You can enter one or more domain names and use the same tag.

Optionally, you can add more than one mail account and authorize it. You can complete the registration process by entering these 3 information.


STEP 2

Add the api connection script and button to your page. Add the code you get from the google page during registration to the data-sitekey value of the button you added.

When the reCAPTCHA button is clicked on the form, you will get a return value.

When the form is sent, this return value will match the secret-key and verify your transaction code you wrote in the background.

When you add class = "g-recaptcha" after connecting the api, your check box will appear. Afterwards, you need to properly process the data-sitekey and secret key fields of your check box.

<!--Api Connect--><br> <script src="https://www.google.com/recaptcha/api.js" async="" defer=""></script>
<form id="signupForm" novalidate  onsubmit="return false" >
	<div class="form-group">
	         <input type="text" name="name" placeholder="Name" required="" class="form-group ">
	</div>
	<div class="form-group">
		<input type="text" name="phone" placeholder="Phone" required="" class="form-group ">
	</div>	
	<div class="form-group">
	        <input type="email" name="email" placeholder="E-Mail" required="" class="form-group ">
	</div>					
	<div class="g-recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div>
        <!--In the xxx field above, write the data key key you received from the reCAPTCHA service.-->
	<button  type="submit" name="submit-form">Send</button>
</form>

<!--Processing the Returned Answer-->

<?php 
if (isset($_POST['g-recaptcha-response'])) {
			$captcha = $_POST['g-recaptcha-response'];
}
if (!$captcha) {
	echo '<script>alert("Please Verify You Are Not A Robot");</script>';
}else{
	$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=xxxxxxxxxxxxxxxxxxx&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
         <! - We add secret code to the xxxx field above .-->
	$backtrue = json_decode($response,true);
      if(intval($backtrue["success"]) == 1) {
		echo "Robot check is successful.";
}}?>
We did a quick robot verification on php server in a html page with the recaptcha I am not a Robot Checkbox. By examining the other versions, you can choose the one that suits you, logic and the process steps may differ.
You can set the operation difficulty in the settings on the reCAPTCHA api page. To increase site security, you can use this google service instead of simple images or mathematical operations that are likely to be overcome.
E.Albayrak

2 Yorum

Melike Tan

Melike Tan

9 ay önce

reCAPTCHA üyeliği nasıl yapılır yardımcı olursanız sevinirim.

Kerem Baykuş

Kerem Baykuş

9 ay önce

https://www.google.com/recaptcha/about/ sitesinde üyelik oluşturup kullanıma başlayabilirsiniz.

Soru & Yorum


Web Tasarım

Renkli Kare

Web Tasarım Ajansı