Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Bucephalus-lgtm/2b392bcec5f7f926f0c0bd7e65a1b667 to your computer and use it in GitHub Desktop.
Save Bucephalus-lgtm/2b392bcec5f7f926f0c0bd7e65a1b667 to your computer and use it in GitHub Desktop.
<?php
error_reporting(0);
if (isset($_POST[‘submit’]) && !empty($_POST[‘submit’])) {
if (isset($_POST[‘g-recaptcha-response’]) && !empty($_POST[‘g-recaptcha-response’])) {
$secret = ‘__your_secret_key__’;
$captchaResponse = file_get_contents(‘https://www.google.com/recaptcha/api/siteverify?secret=’ . $secret . ‘&response=’ . $_POST[‘g-recaptcha-response’]);
$responseData = json_decode($captchaResponse );
if ($responseData->success) {
$name = !empty($_POST[‘name’]) ? $_POST[‘name’] : ”;
$email = !empty($_POST[’email’]) ? $_POST[’email’] : ”;
$password = !empty($_POST[‘pwd’]) ? $_POST[‘pwd’] : ”;
$htmlContent = “
<h1>Registration details</h1>
<p><b>Name: </b>” . $name . “</p>
<p><b>Email: </b>” . $email . “</p>
<p><b>Message: </b>” . $password . “</p>
“;
} else {
$errMsg = ‘Captcha verification failed, please try again.’;
echo “<script>alert(‘” . $errMsg . “‘);</script>”;
}
} else {
$errMsg = ‘Please click on the reCAPTCHA box.’;
echo “<script>alert(‘” . $errMsg . “‘);</script>”;
}
} else {
$errMsg = ”;
echo “<script>alert(‘Please fill data’);</script>”;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment