Wednesday, May 23rd

Last update05:36:30 AM GMT

Font Size

Screen

Profile

Layout

Menu Style

Cpanel
Welcome, Guest
Username Password: Remember me

Adding ReCaptcha to the Registration Form
(1 viewing) (1) Guest
Tips and tricks only - please put all other posts in another forum!
  • Page:
  • 1

TOPIC: Adding ReCaptcha to the Registration Form

Adding ReCaptcha to the Registration Form 2 years, 6 months ago #2262

Adding ReCaptcha to the Registration Form

(EDIT: This is for Joomla 1.5)

I couldn't find precise instructions for Joomla 1.5 anywhere, but the following works for me:


Files to edit:

components/com_user/views/register/tmpl/default.php
components/com_user/controller.php

File to add (from the ReCaptcha website):
components/com_user/views/register/tmpl/recaptchalib.php


Replace the text YOUR-RECAPTCHA-PUBLIC-KEY and YOUR-RECAPTCHA-PRIVATE-KEY in the code below with the actual keys you received from the ReCaptcha website.


At the beginning of default.php ADD:

<script type= "text/javascript">
var RecaptchaOptions = {
theme: 'clean'
};
</script>



Look for the following line in default.php:

<button class="button validate" type="submit"><?php echo JText::_('Register'); ?></button>


BEFORE the line above ADD:

<?php
require_once('recaptchalib.php');
$publickey = "YOUR-RECAPTCHA-PUBLIC-KEY"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>



Look for the following line in controller.php:

global $mainframe;


AFTER this line ADD:

		require_once('views/register/tmpl/recaptchalib.php');
$privatekey = "YOUR-RECAPTCHA-PRIVATE-KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}



That's it!
NicMason.com ~ ARTS.org.au ~ Yarraville.com.au ~ Williamstown.com.au ~ SouthYarra.com.au
Last Edit: 2 years, 6 months ago by NicMason.com.

Re:Adding ReCaptcha to the Registration Form 2 years, 6 months ago #2272

  • austega
  • OFFLINE
  • Senior Boarder
  • Posts: 69
  • Karma: 1
Thanks Nick, and very timely from a personal viewpoint.
Austega Information Services
m 0415 715 743
w austega.com
w big-issues.org

Re:Adding ReCaptcha to the Registration Form 2 years, 6 months ago #2279

  • Partic
  • OFFLINE
  • Moderator
  • Posts: 341
  • Karma: 21
Something to note (having just gone getting keys to recaptcha a week ago) is that there's now a Global Key when you get your REcaptcha key. That means that you don't need to go and get new keys for every site you want to protect using recaptcha.

Thanks for writing this up Nic.
Patrick Jackson
www.kpsystems.com.au
Ask Anything Joomla and I'll helpfully tell you where to go
  • Page:
  • 1
Moderators: austega
Time to create page: 0.92 seconds
You are here: Forum