Using new Google reCAPTCHA using PHP

In the tutorial, I will be using a working HTML contact form. We will submit it post method process the form values with PHP.

Google has released the new reCAPTCHA. They need just a single click to confirm they are not a robot. So, reCAPTCHA will protect your website from spam with better user experience. You can easily integrate Google reCAPTCHA in PHP script.

Header file Code

<script src="" async defer></script>
<script src=""></script>


<form action="submit.php" method="POST">
	<input type="text" required="" class="text" value="" placeholder="Your name" name="name" >
	<input type="email" required="" class="text" value="" placeholder="Email adress" name="email" >
	<textarea type="text" placeholder="Message..." required="" name="message"></textarea>
	<div class="g-recaptcha" data-sitekey=""></div>
	<input type="submit" name="submit" value="SUBMIT">

PHP Code

	$secret = '';
	$verifyResponse = file_get_contents(''.$secret.'&response='.$_POST['g-recaptcha-response']);
	$responseData = json_decode($verifyResponse);
		echo "Success";
		echo "Google reCAPTCHA Expired!!";

Leave a Reply

Your email address will not be published. Required fields are marked *