i have a custom website, no CMS, and this website uses Smarty. The website allow users to register and uses an old image captcha system. To disallow bots registrations, i will implement new Google No Captcha Recaptcha plugin, ( more info here: https://www.google.com/recaptcha/ ).
So i decided to follow this tutorial: https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha-recaptcha-in-your-website--cms-23024
I have no problem in first steps: register on Google and obtain Site Key and Secret Key.
Also no problem in following steps: insert JavaScript API and div box in register.tpl smarty template file .
My problem is in the final steps, send to Google response so it can verify it. This was no problem in normal website to put php code in register.php normal php page. But on Smarty Template, so in register.tpl, it gives me fatal errors, also if i use {php}{/php} special tags
<?php
// grab recaptcha library
require_once "recaptchalib.php";
// your secret key
$secret = "0000000000000000000000000000000000";
// empty response
$response = null;
// check our secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
?>
And this:
<?php
if ($response != null && $response->success) {
echo "Hi " . $_POST["name"] . " (" . $_POST["email"] . "), thanks for submitting the form!";
} else {
?>
<?php } ?>
I think the solution is to put this code in register.php page and import it in register.tpl page, but i am a beginner, can you please transform this code for me ? I am sure this code will be useful for many users around the web.