reCAPTCH not working Please Help

103 views
Skip to first unread message

Joe

unread,
Dec 2, 2011, 8:47:55 PM12/2/11
to reCAPTCHA
I am very new to website design and have built a brochure site for my
mom to try and help her land a few more clients. I am almost done but
having an error when the "Submit" button is pressed on the "Contact
Form"

The url I am using to work out the kinks is:
hillsidemedicalbilling.com/test/

So far I have done the steps outlined in the "Displaying reCAPTCHA
Without Plugins" section using "The Standard Challenge and Non-
JavaScript API" method.

It appears that the given html of

<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?
k=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?
k=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
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>

should be

........................................................................</
iframe><br />
..........................................................................................
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge" />
</noscript>

so I have changed that.

I then placed this script in my header to change it to the appropriate
color scheme:

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

I placed recaptchalib.php in the /test/ directory as instructed.

I created the verify.php file using the script below (this is the
entire verify.php file):

1 <?php
2 require_once('recaptchalib.php');
3 $privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
4
5 if ($_POST["recaptcha_response_field"]) {
6 $response = recaptcha_check_answer (
7 $privatekey, $_SERVER["REMOTE_ADDR"],
8 $_POST["recaptcha_challenge_field"],
9 $_POST["recaptcha_response_field"]);
10
11 if ($response->is_valid) {
12 $show_web_form = 0;
13
14 // Begin: GoDaddy "gdform.php"
15 $request_method = $_SERVER["REQUEST_METHOD"];
16
17 if ($requ.uest_method == "GET"){
18 $query_vars = $_GET;
19 } elseif ($request_method == "POST"){
20 $query_vars = $_POST;
21 }
22
23 reset($query_vars);
24 $t = date("U");
25
26 $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/
gdform_" . $t;
27 $fp = fopen($file,"w");
28 while (list ($key, $val) = each ($query_vars)) {
29 fputs($fp,"<GDFORM_VARIABLE NAME=$key START>
\n");
30 fputs($fp,"$val\n");
31 fputs($fp,"<GDFORM_VARIABLE NAME=$key END>
\n");
32 if ($key == "redirect") { $landing_page =
$val; }
33 }
34
35 fclose($fp);
36 if ($landing_page != ""){
37 header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
38 } else {
39 header("Location: http://".$_SERVER["HTTP_HOST"]."/");
40 }
41 // End: GoDaddy "gdform.php"
42 } else {
43 died ("The reCAPTCHA was not entered correctly. Please go
back and try it again." .
44 "(reCAPTCHA said: " . $resp->error . ")");

I also linked it to the main index.html in the contact page like
this...

<form style="margin-left: 165px; left" action="verify.php"
method="post">

reCAPTCHA is displaying perfectly but I am getting the following error
on a new page when the "Submit" button is pressed.

Parse error: syntax error, unexpected $end in D:\Hosting\8502247\html
\test\verify.php on line 44

My goal is to have an incorrectly entered CAPTCHA display the error
"The reCAPTCHA was not entered correctly. Please go back and try it
again"

A successful submission should send the form contents to the gdform
(godaddy's method of email and a requirement for their email services)
and take the user to the url:
hillsidemedicalbilling.com/thankyou/

I hope someone can help me figure out what the issue is b/c I would
really like to come to a finishing point on this project.

Thanks in advance!

PJH

unread,
Dec 3, 2011, 6:26:36 AM12/3/11
to reca...@googlegroups.com
On Sat, Dec 3, 2011 at 1:47 AM, Joe <jcaho...@gmail.com> wrote:
this is the
entire verify.php file):

1 <?php
[...]
42        } else {
43              died ("The reCAPTCHA was not entered correctly. Please go
back and try it again." .
44               "(reCAPTCHA said: " . $resp->error . ")");

[...]
reCAPTCHA is displaying perfectly but I am getting the following error
on a new page when the "Submit" button is pressed.

Parse error: syntax error, unexpected $end in D:\Hosting\8502247\html
\test\verify.php on line 44

You're missing at least one (probably two) closing brace(s) in your php file, and the closing php delimiter.

--
PJH


Joe

unread,
Dec 7, 2011, 5:28:55 PM12/7/11
to reCAPTCHA
Thanks PJH for the help!

I corrected those issues you mentioned above and it got rid of the
line 44 error.

Now I'm getting 4 other errors that keep repeating. I have tried to
read up on the syntax of the if/else statements and cant figure out
why it is not working. It looks to me that everything should be
working.

Can anyone help me figure this out? Here is the new code in its
entirety:

<?php
require_once('recaptchalib.php');
$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

if ($_POST["recaptcha_response_field"]) {
$response = recaptcha_check_answer (
$privatekey, $_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($response->is_valid) {
$show_web_form = 0;

// Begin: GoDaddy "gdform.php"
$request_method = $_SERVER["REQUEST_METHOD"];

if ($requ.uest_method == "GET"){

$query_vars = $_GET;


} elseif ($request_method == "POST"){

$query_vars = $_POST;
}

reset($query_vars);


$t = date("U");

$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/
gdform_" . $t;


$fp = fopen($file,"w");

while (list ($key, $val) = each ($query_vars)) {

fputs($fp,"<GDFORM_VARIABLE NAME=$key START>
\n");

fputs($fp,"$val\n");


fputs($fp,"<GDFORM_VARIABLE NAME=$key END>
\n");

if ($key == "redirect") { $landing_page =
$val; }
}

fclose($fp);
if ($landing_page != ""){


header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");

} else {


header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}

// End: GoDaddy "gdform.php"
} else {
die ("The reCAPTCHA was not entered correctly. Please go back


and try it again." .

"(reCAPTCHA said: " . $resp->error . ")");
}
}

?>

PJH

unread,
Dec 8, 2011, 6:11:30 AM12/8/11
to reca...@googlegroups.com


On Wed, Dec 7, 2011 at 10:28 PM, Joe <jcaho...@gmail.com> wrote:
Now I'm getting 4 other errors that keep repeating.

And the error messages are...?


               if ($requ.uest_method == "GET"){
                       $query_vars = $_GET;
               } elseif ($request_method == "POST"){
                       $query_vars = $_POST;
               }

I'm certain that period shouldn't be there on that first line.

--
PJH


Joe

unread,
Dec 8, 2011, 5:05:07 PM12/8/11
to reCAPTCHA
I corrected it to read correctly if($request-method=="GET"){
.......

Here are all the errors I am getting.

Warning: fopen(D:\Hosting\8502247\html/../data/gdform_1323381692)
[function.fopen]: failed to open stream: No such file or directory in
D:\Hosting\8502247\html\test\verify.php on line 27

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 30

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 31

Warning: fclose(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 35

Warning: Cannot modify header information - headers already sent by
(output started at D:\Hosting\8502247\html\test\verify.php:35) in D:
\Hosting\8502247\html\test\verify.php on line 39

PJH

unread,
Dec 9, 2011, 2:24:02 AM12/9/11
to reca...@googlegroups.com
On Thu, Dec 8, 2011 at 10:05 PM, Joe <jcaho...@gmail.com> wrote:
Warning: fopen(D:\Hosting\8502247\html/../data/gdform_1323381692)
[function.fopen]: failed to open stream: No such file or directory in
D:\Hosting\8502247\html\test\verify.php on line 27

You have a missing file (or more likely path in this instance - I reckon D:/Hosting/8502247/data.) By the way, you can use / as a delimiter even under Windows.
 

Warning: fputs(): supplied argument is not a valid stream resource in
D:\Hosting\8502247\html\test\verify.php on line 29
[snip]
 
Those errors are as a result of your missing file/path.

Warning: Cannot modify header information - headers already sent by
(output started at D:\Hosting\8502247\html\test\verify.php:35) in D:
\Hosting\8502247\html\test\verify.php on line 39

Your script is producing some output before your call to header() (probably due, again, to your missing path/file.) See http://php.net/manual/en/function.header.php

--
PJH


Reply all
Reply to author
Forward
0 new messages