Captcha On Registration

Post your suggestions for the script here.

Captcha On Registration

Postby typeman » Fri Jan 29, 2010 10:46 pm

I've been fiddling with this for ages, trying to get it to work, but alas to no effect. Is this possible? I'm sure it is :)

I look forward to hearing your ideas! :)

Thanks in advance.
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby Hawk » Sat Jan 30, 2010 1:27 pm

Not sure about the captcha, but I'm quite sure it could be done with reCaptcha, implementation of it is simple, and it provides the protection of the captcha
http://recaptcha.net/
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby typeman » Sat Jan 30, 2010 2:48 pm

Hawk wrote:Not sure about the captcha, but I'm quite sure it could be done with reCaptcha, implementation of it is simple, and it provides the protection of the captcha
http://recaptcha.net/


Hey, thanks for the reply! :) I was using this when I was trying to do it myself, but when I put the code into my TPL file, some of the PHP went a bit screwy...

Basically, I put the PHP code into it, and some of the code was getting left out and just returning it back to me as plain text.

This is the PHP for the recapture:

Code: Select all
<?php

require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "1234567898";
$privatekey = "1123445566";

# 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;
        }
}
echo recaptcha_get_html($publickey, $error);
?>


However, this bit of code then is what is displayed as regular text:

Code: Select all
is_valid) {
                echo "You got it!";
        } else {
                # set the error code so that we can display it
                $error = $resp->error;
        }
}
echo recaptcha_get_html($publickey, $error);
?>


Which obviously messes up the code. So any ideas? :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby Hawk » Sun Jan 31, 2010 3:36 pm

Hm, could you tell me in which file you are trying to implement the code?

I personally didn't try to include recaptcha in cnr, but based on how I included recaptcha on other scripts, I think it would work like this:

1. Upload the recaptchalib.php on your website.

2. Add following code into the cnr/inc/mod/editusers.mdu right after <?php
Code: Select all
require_once('path-to-recaptcha-lib/recaptchalib.php');
$privatekey = "your-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 . ")");
}

3. Include this code into the registration form:
Code: Select all
<div align="center">
          <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Ld3gQUAAAAAADeIGizPe5hJgIzpWvGKNIyFRm1a"></script>
                             
          <noscript>
          <iframe src="http://api.recaptcha.net/noscript?k=6Ld3gQUAAAAAADeIGizPe5hJgIzpWvGKNIyFRm1a" height="300" width="500" frameborder="0"></iframe><br/>
          <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
          <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
          </noscript>
</div>
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby Hawk » Sun Jan 31, 2010 3:37 pm

forum went wild... post for delete
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby typeman » Mon Feb 01, 2010 12:16 am

Hawk wrote:Hm, could you tell me in which file you are trying to implement the code?

I personally didn't try to include recaptcha in cnr, but based on how I included recaptcha on other scripts, I think it would work like this:

1. Upload the recaptchalib.php on your website.

2. Add following code into the cnr/inc/mod/editusers.mdu right after <?php
Code: Select all
require_once('path-to-recaptcha-lib/recaptchalib.php');
$privatekey = "your-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 . ")");
}

3. Include this code into the registration form:
Code: Select all
<div align="center">
          <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6Ld3gQUAAAAAADeIGizPe5hJgIzpWvGKNIyFRm1a"></script>
                             
          <noscript>
          <iframe src="http://api.recaptcha.net/noscript?k=6Ld3gQUAAAAAADeIGizPe5hJgIzpWvGKNIyFRm1a" height="300" width="500" frameborder="0"></iframe><br/>
          <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
          <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
          </noscript>
</div>


Hey, thanks for that :) I have the form all filled in, but now the recapture stuff isn't working. For some reason, if the codes wrong, then it just totally ignores it and continues and submits for the form. I made sure that the file was looking in the right place for recaptchalib.php, but yet, it doesn't work... =\

Any ideas? :)

Thank you for the assistance! :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby Hawk » Tue Feb 02, 2010 8:50 pm

I forgot to wrote that in the 2nd piece of code you need to enter your public key which you got from recaptcha (you can check it on their website too after you login).
Code: Select all
<div align="center">
          <script type="text/javascript" src="http://api.recaptcha.net/challenge?k={here-comes-public-key}"></script>
                             
          <noscript>
          <iframe src="http://api.recaptcha.net/noscript?k={here-comes-public-key}" height="300" width="500" frameborder="0"></iframe><br/>
          <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
          <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
          </noscript>
</div>


If the recaptcha gets skipped, it means that the code isn't implemented correctly. You could try to put recaptchalib.php into the same directory as eduitusers.mdu and see if that will make any effect.
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

Postby typeman » Wed Feb 03, 2010 12:21 am

Hawk wrote:I forgot to wrote that in the 2nd piece of code you need to enter your public key which you got from recaptcha (you can check it on their website too after you login).
Code: Select all
<div align="center">
          <script type="text/javascript" src="http://api.recaptcha.net/challenge?k={here-comes-public-key}"></script>
                             
          <noscript>
          <iframe src="http://api.recaptcha.net/noscript?k={here-comes-public-key}" height="300" width="500" frameborder="0"></iframe><br/>
          <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
          <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
          </noscript>
</div>


If the recaptcha gets skipped, it means that the code isn't implemented correctly. You could try to put recaptchalib.php into the same directory as eduitusers.mdu and see if that will make any effect.


Hey, I tried that and I also tried your suggestion of moving recatptchalib.php to the same directory, however, it's still the same as before. I also noticed that my mod=editusers in CNRU is now displaying this:
The reCAPTCHA was not entered correctly. Go back and try it again.(reCAPTCHA said: incorrect-captcha-sol)


Which as you can tell isn't too helpful ;)

Thanks for the continued help! :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am


Return to Suggestions



Who is online

Users browsing this forum: No registered users and 1 guest