Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Recaptcha with smarty

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
sbalay
Smarty Rookie


Joined: 30 Aug 2011
Posts: 5

PostPosted: Tue Sep 13, 2011 2:13 pm    Post subject: Recaptcha with smarty Reply with quote

Have anyone tried to integrate reCaptcha with smarty templates..

Any suggestions...

Thanks.!!
Back to top
View user's profile Send private message
androidworkz
Smarty Rookie


Joined: 08 Aug 2011
Posts: 15

PostPosted: Tue Sep 13, 2011 7:39 pm    Post subject: Reply with quote

What would be so difficult about doing that?

register.php
Code:

require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "<public_key>";
$privatekey = "<private_key>";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
        $resp = recaptcha_check_answer ($privatekey,
                                        $_SERVER["REMOTE_ADDR"],
                                        $_POST["recaptcha_challenge_field"],
                                        $_POST["recaptcha_response_field"]);

        if ($resp->is_valid) {
                echo "You got it!";
        } else {
                # set the error code so that we can display it
                $error = $resp->error;
        }
}

$smarty->assign("recaptcha", recaptcha_get_html($pub_key, $error));


register.tpl
Code:

{nocache}
{$recaptcha}
{/nocache}
Back to top
View user's profile Send private message
syslogic
Smarty n00b


Joined: 06 Oct 2011
Posts: 2

PostPosted: Thu Oct 06, 2011 12:36 am    Post subject: Example Reply with quote

I've posted a commented example to my blog.
Back to top
View user's profile Send private message
atomant
Smarty n00b


Joined: 15 Feb 2019
Posts: 2

PostPosted: Fri Feb 15, 2019 2:53 am    Post subject: Reply with quote

What about reCaptchav3?
I can't get it working.
Smarty have remove the usage of {php} tags now
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1545

PostPosted: Sat Feb 16, 2019 7:21 am    Post subject: Reply with quote

Eight years passed…
Please post your question in a separate thread, with your code displaying your attempts and an explanation of what doesn't work for you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP