Instantly share code, notes, and snippets.

@kaplanmaxe /mail.php
Last active Jul 22, 2018

What would you like to do?
PHP Recaptcha PHP tutorial
$sender_name = stripslashes($_POST["sender_name"]);
$sender_email = stripslashes($_POST["sender_email"]);
$sender_message = stripslashes($_POST["sender_message"]);
$response = $_POST["g-recaptcha-response"];
$url = '';
$data = array(
'secret' => 'YOUR_SECRET',
'response' => $_POST["g-recaptcha-response"]
$options = array(
'http' => array (
'method' => 'POST',
'content' => http_build_query($data)
$context = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
if ($captcha_success->success==false) {
echo "<p>You are a bot! Go away!</p>";
} else if ($captcha_success->success==true) {
echo "<p>You are not not a bot!</p>";

This comment has been minimized.

jrsconfitto commented Jun 14, 2017

Thanks for this!


This comment has been minimized.

anil5594 commented Apr 9, 2018

Hi this side is Anil i have a problem with this code my server hosting PHP version is PHP 5.6.35 and form link is not working on this site but on another hosting account with PHP version: 7.1.14 for this form same code is running successfully.
so can you suggest me what is the exact problem is it php version problem or any other problem.

thanks in Advance.


This comment has been minimized.

BillyCrook commented Apr 30, 2018

$response is never used. I would recommend using it in line 10, or deleting line 5.


This comment has been minimized.

computekie commented Jul 22, 2018

ok half the code is missing... ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment