Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Recaptcha with smarty

 
Post new topic   Reply to topic    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
Display posts from previous:   
Post new topic   Reply to topic    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