Adding reCAPTCHA to form using PHP

Adding reCAPTCHA to form using PHP

am 19.04.2010 18:21:14 von Ernie Kemp

------=_NextPart_000_0018_01CADFBA.CEADFAE0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Need help with reCAPTCHA. Never installed it before.

When Submit is clicked the "quoterequest-redirect.php" is run but I think it
would be better to test the reCAPTCHA before the "quoterequest-redirect.php"
program has been run.

I check the CAPTCHA in "quoterequest-redirect.php", it displays a invalid
message if invalid but the user has to tab back to fill in the CAPTCHA
again.



The reCAPTCHA show correctly but I need some help/hints/tips here.



Thanks very much again,

...../Ernie

***********************************************************








// call the lib..

require_once('recaptchalib.php');



// Get a key from http://recaptcha.net/api/getkey

$publickey = "6LeGhwwAAAAAADNm2bEIkxzNHXIjpAlGYJ5NCYju";

$privatekey = "6LeGhwwAAAAAAFbi37aANuHliCnZ-_jg3uN8N7oh";



# the response from reCAPTCHA

$resp = null;

# the error code from reCAPTCHA, if any

$error = null;



# was there a reCAPTCHA response?

if ($_POST["submit"]) {

$response = recaptcha_check_answer($privatekey,

$_SERVER["REMOTE_ADDR"],

$_POST["recaptcha_challenge_field"],

$_POST["recaptcha_response_field"]);



if ($response->is_valid) {

echo "Yes, that was correct!";

} else {

# set the error code so that we can display it

echo "Eh, That wasn't right. Try Again.";



}

}

?>







































No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2814 - Release Date: 04/16/10
02:31:00


------=_NextPart_000_0018_01CADFBA.CEADFAE0--

Re: Adding reCAPTCHA to form using PHP

am 19.04.2010 18:50:30 von TedD

At 12:21 PM -0400 4/19/10, Ernie Kemp wrote:
>Need help with reCAPTCHA. Never installed it before.
>
>When Submit is clicked the "quoterequest-redirect.php" is run but I think it
>would be better to test the reCAPTCHA before the "quoterequest-redirect.php"
>program has been run.
>
>I check the CAPTCHA in "quoterequest-redirect.php", it displays a invalid
>message if invalid but the user has to tab back to fill in the CAPTCHA
>again.
>
>
>
>The reCAPTCHA show correctly but I need some help/hints/tips here.

Ernie :

There's nothing complicated here. You don't need to get public and
private keys or other such complications. A CAPTCHA is as simple as:

What is 2 + 2?
What is the color of an orange?

Answer correctly and you pass. If not, then you don't.

The purpose of a CAPTCHA is simply to keep bots out and allow humans
to pass. If you base your CAPTCHA on a strange graphic, then you keep
visually impaired users out. That's not good.

Here's an assortment of CAPTCHA's, but I think the Question CAPTCHA
is the best.

http://webbytedd.com/aa/assorted-captcha/


Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Adding reCAPTCHA to form using PHP

am 19.04.2010 19:42:45 von Ernie Kemp

Thanks for your reply Tedd.
Maybe my reCAPTCHA is more complicated than it needs to be but when you
click the "Submit" button the form triggers the
action="quoterequest-redirect.php" which goes to another program without
checking the CAPTCHA. I test in the called program and display a message if
it's invalid. The user then clicks back to form page to try again.
It would be better on submit the program would display an error message and
go nowhere.

The code works by itself but in a form with an action, not so good.

Not such how to do this....




// call the lib..
require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6LeGhwwAAAAAADNm2bEIkxzNHXIjpAlGYJ5NCYju";
$privatekey = "6LeGhwwAAAAAAFbi37aANuHliCnZ-_jg3uN8N7oh";

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

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

if ($response->is_valid) {
echo "Yes, that was correct!";
} else {
# set the error code so that we can display it
echo "Eh, That wasn't right. Try Again.";
}
}
?>








-----Original Message-----
From: tedd [mailto:tedd.sperling@gmail.com]
Sent: April-19-10 12:51 PM
To: Ernie Kemp; 'PHP General List'
Subject: Re: [PHP] Adding reCAPTCHA to form using PHP

At 12:21 PM -0400 4/19/10, Ernie Kemp wrote:
>Need help with reCAPTCHA. Never installed it before.
>
>When Submit is clicked the "quoterequest-redirect.php" is run but I think
it
>would be better to test the reCAPTCHA before the
"quoterequest-redirect.php"
>program has been run.
>
>I check the CAPTCHA in "quoterequest-redirect.php", it displays a invalid
>message if invalid but the user has to tab back to fill in the CAPTCHA
>again.
>
>
>
>The reCAPTCHA show correctly but I need some help/hints/tips here.

Ernie :

There's nothing complicated here. You don't need to get public and
private keys or other such complications. A CAPTCHA is as simple as:

What is 2 + 2?
What is the color of an orange?

Answer correctly and you pass. If not, then you don't.

The purpose of a CAPTCHA is simply to keep bots out and allow humans
to pass. If you base your CAPTCHA on a strange graphic, then you keep
visually impaired users out. That's not good.

Here's an assortment of CAPTCHA's, but I think the Question CAPTCHA
is the best.

http://webbytedd.com/aa/assorted-captcha/


Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2819 - Release Date: 04/19/10
02:31:00


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Adding reCAPTCHA to form using PHP

am 19.04.2010 20:10:58 von Andrew Ballard

On Mon, Apr 19, 2010 at 12:50 PM, tedd wrote:
> At 12:21 PM -0400 4/19/10, Ernie Kemp wrote:
>>
>> Need help with reCAPTCHA. Never installed it before.
>>
>> When Submit is clicked the "quoterequest-redirect.php" is run but I thin=
k
>> it
>> would be better to test the reCAPTCHA before the
>> "quoterequest-redirect.php"
>> program has been run.
>>
>> I check the CAPTCHA in "quoterequest-redirect.php", it displays a invali=
d
>> message if invalid but the user has to tab back to fill in the CAPTCHA
>> again.
>>
>>
>>
>> The reCAPTCHA show correctly but I need some help/hints/tips here.
>
> Ernie :
>
> There's nothing complicated here. You don't need to get public and privat=
e
> keys or other such complications. A CAPTCHA is as simple as:
>
> What is 2 + 2?
> What is the color of an orange?
>
> Answer correctly and you pass. If not, then you don't.
>
> The purpose of a CAPTCHA is simply to keep bots out and allow humans to
> pass. If you base your CAPTCHA on a strange graphic, then you keep visual=
ly
> impaired users out. That's not good.
>
> Here's an assortment of CAPTCHA's, but I think the Question CAPTCHA is th=
e
> best.
>
> http://webbytedd.com/aa/assorted-captcha/
>
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthston=
es.com
>

Yes, but I assumed he meant reCAPTCA, not simply CAPTCHA. The former
is a specific implementation of the latter.

http://recaptcha.net/

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Adding reCAPTCHA to form using PHP

am 19.04.2010 21:08:08 von TedD

At 2:10 PM -0400 4/19/10, Andrew Ballard wrote:
>On Mon, Apr 19, 2010 at 12:50 PM, tedd wrote:
>> At 12:21 PM -0400 4/19/10, Ernie Kemp wrote:
>>>
>>> Need help with reCAPTCHA. Never installed it before.
>>>
>>> When Submit is clicked the "quoterequest-redirect.php" is run but I think
>>> it
>>> would be better to test the reCAPTCHA before the
>>> "quoterequest-redirect.php"
>>> program has been run.
>>>
>>> I check the CAPTCHA in "quoterequest-redirect.php", it displays a invalid
>>> message if invalid but the user has to tab back to fill in the CAPTCHA
>>> again.
>>>
>>>
>>>
>>> The reCAPTCHA show correctly but I need some help/hints/tips here.
>>
>> Ernie :
>>
>> There's nothing complicated here. You don't need to get public and private
>> keys or other such complications. A CAPTCHA is as simple as:
>>
>> What is 2 + 2?
>> What is the color of an orange?
>>
>> Answer correctly and you pass. If not, then you don't.
>>
>> The purpose of a CAPTCHA is simply to keep bots out and allow humans to
>> pass. If you base your CAPTCHA on a strange graphic, then you keep visually
>> impaired users out. That's not good.
>>
>> Here's an assortment of CAPTCHA's, but I think the Question CAPTCHA is the
>> best.
>>
>> http://webbytedd.com/aa/assorted-captcha/
>>
>>
>> Cheers,
>>
>> tedd
>> --
>> -------
>> http://sperling.com http://ancientstones.com http://earthstones.com
>>
>
>Yes, but I assumed he meant reCAPTCA, not simply CAPTCHA. The former
>is a specific implementation of the latter.
>
>http://recaptcha.net/
>
>Andrew

Andrew:

Yes, I realize that. But what I said about the technique stopping the
visually impaired is equally true. If you care nothing about those
types of folks, then proceed (by the Grace of God) along your sighted
way.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Adding reCAPTCHA to form using PHP

am 21.04.2010 19:14:39 von Ernie Kemp

Hope I'm not flogging a dead horse but I'm trying to understand how to show
error message for reCAPTCHA on the same page as the form.

I need to go to action="quoterequest-redirect.php" page. The submit alway
goes to the action where I can check the reCAPTCHA'd enterd but it would be
nice to have the messsage appear on the same Login page.

Please remind me/give me a hint.

Thanks,
...../Ernie


Thanks for your reply Tedd.
Maybe my reCAPTCHA is more complicated than it needs to be but when you
click the "Submit" button the form triggers the
action="quoterequest-redirect.php" which goes to another program without
checking the CAPTCHA. I test in the called program and display a message if
it's invalid. The user then clicks back to form page to try again.
It would be better on submit the program would display an error message and
go nowhere.

The code works by itself but in a form with an action, not so good.

Not such how to do this....




// call the lib..
require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6LeGhwwAAAAAADNm2bEIkxzNHXIjpAlGYJ5NCYju";
$privatekey = "6LeGhwwAAAAAAFbi37aANuHliCnZ-_jg3uN8N7oh";

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

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

if ($response->is_valid) {
echo "Yes, that was correct!";
} else {
# set the error code so that we can display it
echo "Eh, That wasn't right. Try Again.";
}
}
?>








-----Original Message-----
From: tedd [mailto:tedd.sperling@gmail.com]
Sent: April-19-10 12:51 PM
To: Ernie Kemp; 'PHP General List'
Subject: Re: [PHP] Adding reCAPTCHA to form using PHP

At 12:21 PM -0400 4/19/10, Ernie Kemp wrote:
>Need help with reCAPTCHA. Never installed it before.
>
>When Submit is clicked the "quoterequest-redirect.php" is run but I think
it
>would be better to test the reCAPTCHA before the
"quoterequest-redirect.php"
>program has been run.
>
>I check the CAPTCHA in "quoterequest-redirect.php", it displays a invalid
>message if invalid but the user has to tab back to fill in the CAPTCHA
>again.
>
>
>
>The reCAPTCHA show correctly but I need some help/hints/tips here.

Ernie :

There's nothing complicated here. You don't need to get public and
private keys or other such complications. A CAPTCHA is as simple as:

What is 2 + 2?
What is the color of an orange?

Answer correctly and you pass. If not, then you don't.

The purpose of a CAPTCHA is simply to keep bots out and allow humans
to pass. If you base your CAPTCHA on a strange graphic, then you keep
visually impaired users out. That's not good.

Here's an assortment of CAPTCHA's, but I think the Question CAPTCHA
is the best.

http://webbytedd.com/aa/assorted-captcha/


Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2819 - Release Date: 04/19/10
02:31:00


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.801 / Virus Database: 271.1.1/2819 - Release Date: 04/19/10
02:31:00


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php