Re-Captcha Not working

957 views
Skip to first unread message

sensors

unread,
Apr 13, 2011, 10:13:28 AM4/13/11
to reCAPTCHA
I've set up recaptcha on all of the contact forms on our website. They
were working before (as I have tested them previously), but now they
are not returning the "Success! Your form was submitted" page, but
instead "Recaptcha was not entered correctly". I have checked the
coding on my forms and submit pages but am not finding anything that
has been changed since I tested the recaptcha last week.

PJH

unread,
Apr 13, 2011, 10:25:18 AM4/13/11
to reca...@googlegroups.com
Nothing (obvious) has changed  with reCAPTCHA recently in this regard - the forms on my site still work.
--
PJH


sensors

unread,
Apr 13, 2011, 10:32:39 AM4/13/11
to reCAPTCHA
I recently added the re-captcha script to our website on each form. On
testing, the re-captcha worked fine last week. However, since today it
responds with a "Recaptcha wasn't entered correctly, please go back
and try again", even if the recaptcha was entered correctly. I have
checked the coding and programming on both the submission page and
form page and nothing seems inaccurate. Does anyone have any ideas as
to why this might be occuring?

sensors

unread,
Apr 13, 2011, 10:36:46 AM4/13/11
to reCAPTCHA
Here is my code for the form submission page; -

<?php
require_once('../../../files/scripts/recaptchalib.php');
$privatekey = "6LeSVcASAAAAAFjvemDqQrBURSLX2cy31G5Zj7f_";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("<p>The reCAPTCHA wasn't entered correctly. Go back and try
it again.</p>" .
"(reCAPTCHA said: " . $resp->error . ")");
} else {

[MY VALIDATION CHECKS HERE]

}
?>

On Apr 13, 3:25 pm, PJH <pauljherr...@gmail.com> wrote:
> Nothing (obvious) has changed  with reCAPTCHA recently in this regard - the
> forms on my site still work.
>

PJH

unread,
Apr 13, 2011, 11:23:37 AM4/13/11
to reca...@googlegroups.com
<http://groups.google.com/group/recaptcha/browse_thread/thread/a43f4757392b2290/0af535738181eee9?#0af535738181eee9>


--
You received this message because you are subscribed to the Google Groups "reCAPTCHA" group.
To post to this group, send email to reca...@googlegroups.com.
To unsubscribe from this group, send email to recaptcha+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/recaptcha?hl=en.




--
PJH


sensors

unread,
Apr 14, 2011, 10:31:45 AM4/14/11
to reCAPTCHA
Just tried that,

it returns this:

Array
(
)

The reCAPTCHA wasn't entered correctly. Go back and try it again.
(reCAPTCHA said: incorrect-captcha-sol)

On Apr 13, 4:23 pm, PJH <pauljherr...@gmail.com> wrote:
> <http://groups.google.com/group/recaptcha/browse_thread/thread/a43f475...

PJH

unread,
Apr 14, 2011, 10:40:07 AM4/14/11
to reca...@googlegroups.com


On Thu, Apr 14, 2011 at 3:31 PM, sensors <webm...@sensors.co.uk> wrote:
Just tried that,

it returns this:

Array
(
)

It shouldn't. It should contain the data from your form. Which will include the reCAPTCHA entry.

You're getting incorrect-captcha-sol because you're passing blank/empty/unset strings to it.

An example of what you should be getting back (from the example code on a different thread):

Array
(
    [First_Name] => First
    [Surname] => Sur
    [Email] => Em...@example.com
    [Phone] => Phone
    [User_Type] => home
    [Message] => Message
    [recaptcha_challenge_field] => 03AHJ_Vuunay3pybHkJvxYeTpw1HnCdxSYsMPBQdsDvISz7ia_7mrZjNWZhA8poxVGUvUBe7_Bw7zkl36uNYGwDItJJ4i0fUnPol0aDiBmXTC5XCso2ZDbVlXV5a0pn1sJQX8cBmjkJ5crFrFdB-jEwEzgjyhDRgp0PQ
    [recaptcha_response_field] => nteselys cedric
    [Submit] => Submit
)
You should have, at a minimum, the two bolded lines in order for your form to be useful and pass the captcha tests.

--
PJH


sensors

unread,
Apr 14, 2011, 10:57:42 AM4/14/11
to reCAPTCHA
I have got this in my form submission page (submission/index.php)


<?php
require_once('http://www.sensors.co.uk/files/scripts/
recaptchalib.php');
$privatekey = "6LeSVcASAAAAAFjvemDqQrBURSLX2cy31G5Zj7f_";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("<p>The reCAPTCHA wasn't entered correctly. Go back and try
it again.</p>" .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
if (!$_POST['email']) { exit("<b><center>You did not supply an E-Mail
address. We need this to reply to your E-Mails.<br /><br /><a
href='JavaScript:history.go(-1)'> &lchev; Go Back</a></center></
b>"); }
if (!$_POST['thename']) { exit("<b><center>You did not supply a name.
Please go back and try again.<br /><br /><a
href='JavaScript:history.go(-1)'> &lchev; Go Back</a></center></
b>"); }
if (!$_POST['companyname']) { exit("<b><center>You did not supply a
company name. Please go back and try again.<br /><br /><a
href='JavaScript:history.go(-1)'> &lchev; Go Back</a></center></
b>"); }
if (!$_POST['address']) { exit("<b><center>You did not supply an
address. Please go back and try again.<br /><br /><a
href='JavaScript:history.go(-1)'> &lchev; Go Back</a></center></
b>"); }
else { $name=$_POST['thename']; }
$email=$_POST['email'];
$companyname=$_POST['companyname'];
$method=$_POST['method'];
$address=$_POST['address'];
$ReferURL=$_POST['ReferURL'];
$ReferDate=$_POST['ReferDate'];
$subj=$_POST['subj'];
if ($subj=='') { $subj="Not Supplied"; }
if (!$_POST['message']) { $mess='<i>Not Supplied</i>'; }
else { $mess=$_POST['message']; }
$mess="<b><u>Name:</u></b> ".$name."<br /><b><u>Preferred Method:</u></
b> ".$method."<br /><b><u>Company Name:</u></b> ".$companyname."<br /
><b><u>Address:</u></b> ".$address."<br /><b><u>Refererring Webpage:</
u></b> ".$ReferURL."<br /><b><u>Date:</u></b> " .$ReferDate;
mail("MY EMAIL ADDRESS",$subj,$mess,"Content-type:text/html\r\nFrom:".
$email);
echo "Your message has been successfully sent.";
}
?>

On Apr 14, 3:40 pm, PJH <pauljherr...@gmail.com> wrote:
> On Thu, Apr 14, 2011 at 3:31 PM, sensors <webmas...@sensors.co.uk> wrote:
> > Just tried that,
>
> > it returns this:
>
> > Array
> > (
> > )
>
> It shouldn't. It should contain the data from your form. Which will include
> the reCAPTCHA entry.
>
> You're getting incorrect-captcha-sol because you're passing
> blank/empty/unset strings to it.
>
> An example of what you *should* be getting back (from the example code on a
> different thread):
>
> Array
> (
>     [First_Name] => First
>     [Surname] => Sur
>     [Email] => Em...@example.com
>     [Phone] => Phone
>     [User_Type] => home
>     [Message] => Message*    [recaptcha_challenge_field] =>
> 03AHJ_Vuunay3pybHkJvxYeTpw1HnCdxSYsMPBQdsDvISz7ia_7mrZjNWZhA8poxVGUvUBe7_Bw7zkl36uNYGwDItJJ4i0fUnPol0aDiBmXTC5XCso2ZDbVlXV5a0pn1sJQX8cBmjkJ5crFrFdB-jEwEzgjyhDRgp0PQ
>     [recaptcha_response_field] => nteselys cedric*

PJH

unread,
Apr 14, 2011, 11:06:12 AM4/14/11
to reca...@googlegroups.com


On Thu, Apr 14, 2011 at 3:57 PM, sensors <webm...@sensors.co.uk> wrote:
I have got this in my form submission page (submission/index.php)

We need the code for the page before that - the page that has the <form></form> tags in it and that /should/ be populating your $_POST.

--
PJH


sensors

unread,
Apr 14, 2011, 11:10:42 AM4/14/11
to reCAPTCHA
I've snipped all the other HTML out, here is the code that produces
the form and actions....

<div id="maincol">
<form action="submission/index.php" method="post">
<table align="center" class="table" style="width:450px;">
<tr>
<td><h3>Name:</h3></td>
<td><input type='text' name='thename' /></td>
</tr>
<tr>
<td><h3>Preferred Method:</h3></td>
<td><select name='method'>
<option value='Hard Copy'>Hard Copy</option><option value='Electronic
Copy'>Electronic Copy</option>
</select></td>
</tr>
<tr>
<td><h3>Company Name:</h3></td>
<td><input type='text' name='companyname' /></td>
</tr>
<tr>
<td><h3>Address:</h3></td>
<td><textarea name='address' rows='5' cols='21'></textarea></td>
</tr>
<tr>
<td><h3>Email Address:</h3></td>
<td><input type='text' name='email' /></td>
</tr>
<tr>
<td colspan="2">
<input type='hidden' name='subj' value='Brochure Request'>
</td>
</tr>
<tr>
<td colspan="2"> <script type="text/javascript">
<!--//start hiding
document.write('<input type="hidden" name="ReferURL" value="' +
cRefer + '">');
document.write('<input type="hidden" name="ReferDate" value="' +
cDateRef + '">');
//end hiding-->
</script></td></tr>
<tr>
<td><h3>Captcha:</h3</td>
<td><p>Please enter this to help us verify you are human!</p>
<?php
require_once('http://www.sensors.co.uk/files/scripts/
recaptchalib.php');
$publickey = "6LeSVcASAAAAAPT4_5u9sIc70BSRsr-PPDPVnzYB"; //
you got this from the signup page
echo recaptcha_get_html($publickey);
?>
</td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='Submit' /><input type='reset'
value='Clear' /></td>
</tr>
</table>
</form>
</div>

On Apr 14, 4:06 pm, PJH <pauljherr...@gmail.com> wrote:

PJH

unread,
Apr 14, 2011, 11:16:52 AM4/14/11
to reca...@googlegroups.com


On Thu, Apr 14, 2011 at 4:10 PM, sensors <webm...@sensors.co.uk> wrote:
I've snipped all the other HTML out, here is the code that produces
the form and actions....

Hmm. As with the other query that I've replied to today - it works as I'd expect it to for me:

Changes made:
1) Keys to those of my server
2) paths to recaptchalib.php
3) Changed the test to:

 if (!$resp->is_valid) {
   // What happens when the CAPTCHA was entered incorrectly
   die ("<p>The reCAPTCHA wasn't entered correctly. Go back and try it again.</p>" . "(reCAPTCHA said: " . $resp->error . ")");
 } else {
    die("success");
}

Where the bold bit replaces all your tests for the other stuff in $_POST.

Running at: <http://shabble.co.uk/webm...@sensors.co.uk/submit.php>

--
PJH


sensors

unread,
Apr 14, 2011, 11:35:54 AM4/14/11
to reCAPTCHA
Interesting. Do you think it might be to do with the fact I have
used .htaccess to remove /index.php from the URI? It still seems to
get the file submission/index.php file, but I've noticed even after
removing the captcha it won't validate with my own validation rules
like it used to before. The website I am using with the forms was
recently upgraded (by myself). I tested these forms on the new pages
to ensure they worked properly and they did. But since testing, the
only change I can think that I've made that might possibly cause it,
is the removal of /index.php from URLs via the .htaccess file.

Is that a likely possibility?


On Apr 14, 4:16 pm, PJH <pauljherr...@gmail.com> wrote:
> On Thu, Apr 14, 2011 at 4:10 PM, sensors <webmas...@sensors.co.uk> wrote:
> > I've snipped all the other HTML out, here is the code that produces
> > the form and actions....
>
> Hmm. As with the other query that I've replied to today - it works as I'd
> expect it to for me:
>
> Changes made:
> 1) Keys to those of my server
> 2) paths to recaptchalib.php
> 3) Changed the test to:
>
>  if (!$resp->is_valid) {>>    // What happens when the CAPTCHA was entered incorrectly
> >>    die ("<p>The reCAPTCHA wasn't entered correctly. Go back and try it
> >> again.</p>" . "(reCAPTCHA said: " . $resp->error . ")");
> >>  } else {
> >> *    die("success");*
> >> }
>
> Where the bold bit replaces all your tests for the other stuff in $_POST.
>
> Running at: <http://shabble.co.uk/webmas...@sensors.co.uk/submit.php>
>
> --
> PJH

PJH

unread,
Apr 14, 2011, 11:44:48 AM4/14/11
to reca...@googlegroups.com
Well I don't have any relevant .htaccess on mine, so it's a possibility.

Try commenting out the relevant rules in your .htaccess?

Any particular reason you're trying to remove  index.* from the URLs?
--
You received this message because you are subscribed to the Google Groups "reCAPTCHA" group.
To post to this group, send email to reca...@googlegroups.com.
To unsubscribe from this group, send email to recaptcha+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/recaptcha?hl=en.




--
PJH


sensors

unread,
Apr 15, 2011, 4:16:17 AM4/15/11
to reCAPTCHA
Yes, for SEO friendliness reasons.. for example www.mysite.com/whatever-the-page-is-called
is better for search engines than www.mysite.com/whatever-the-page-is-called/index.php
or /anotherpageinthisdirectory.php

PJH

unread,
Apr 15, 2011, 4:18:52 AM4/15/11
to reca...@googlegroups.com
So simply don't reference www.mysite.com/whatever-the-page-is-called/index.php anywhere- if your webserver is configured sanely then www.mysite.com/whatever-the-page-is-called will give you that page anyway. (i.e. it'll notice there's an index.php file in that directory and serve that up instead of a 404 or a directory listing.)

(Though I'm not sold on the whole SEO concept regarding index.* files - I'd hope Google et alia are smarter than that.)

sensors

unread,
Apr 15, 2011, 4:31:49 AM4/15/11
to reCAPTCHA
I've worked out the problem by changing index.php to "success.php" for
the form output page, and it has made my form validate. I will now re-
instate the recaptcha and try it with that again!!

sensors

unread,
Apr 15, 2011, 4:33:48 AM4/15/11
to reCAPTCHA
Yep, I have just worked out the problem by renaming my submission
(form output file) from index.php to "success.php", so now my form
validation is working. I will now re-instate the captcha and hopefully
it should work!

On Apr 15, 9:18 am, PJH <pauljherr...@gmail.com> wrote:
> So simply don't referencewww.mysite.com/whatever-the-page-is-called/index.phpanywhere- if your
> webserver is configured sanely thenwww.mysite.com/whatever-the-page-is-calledwill give you that page anyway.

Thomas Whitten

unread,
Dec 29, 2016, 7:14:50 AM12/29/16
to reCAPTCHA
I have found that setting your computers to the google.com dns servers solved my problems.  I'm not going into how to do that here but first, google the IP address of the google.com dns servers.  Then go into your control panel, choose the network connection you're using, click properties, IPv4, then override the default DNS servers box to use the google dns servers.

Google likes to seriously track everyone using it so when I get done with the recaptcha, I set all my dns resolution servers back to default.
Reply all
Reply to author
Forward
0 new messages