 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
sbalay Smarty Rookie
Joined: 30 Aug 2011 Posts: 5
|
Posted: Tue Sep 13, 2011 2:13 pm Post subject: Recaptcha with smarty |
|
|
Have anyone tried to integrate reCaptcha with smarty templates..
Any suggestions...
Thanks.!! |
|
| Back to top |
|
androidworkz Smarty Rookie
Joined: 08 Aug 2011 Posts: 15
|
Posted: Tue Sep 13, 2011 7:39 pm Post subject: |
|
|
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 |
|
syslogic Smarty n00b
Joined: 06 Oct 2011 Posts: 2
|
Posted: Thu Oct 06, 2011 12:36 am Post subject: Example |
|
|
| I've posted a commented example to my blog. |
|
| Back to top |
|
|
|
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
|