recaptcha handler returns a totally blank page

220 views
Skip to first unread message

Rhiozan

unread,
Aug 8, 2013, 3:38:42 AM8/8/13
to reca...@googlegroups.com
Salutations, oh great hivemind!

I have a small php project and recently I decided to add a feedback page where the user can complain about my crappy service and so on. There is a form page that has few text fields without any validation and there is a form handling page that has anti sql injections implementations and should act only if recaptcha passed successfully else it redirects back. The overall design is simple till the point of stupidity.  The recaptcha on the form page works just fine. Everything is displayed and works well, but the handler page simply returns nothing. I mean totally nothing, its HTML source is empty regardless of the recaptcha fail or pass. But it shouldnt, really. The page works somewhat ok if i leave the recaptcha field blank and submit the form like that. In this case the handling page informs me "CAPTCHA failed (incorrect-captcha-sol)!" just as i would want it to do. This is really weird. Seems like Recaptcha is unable to perform a logical calculation. Maybe i should change something in the php settings? Here is the code:

<?php
echo "<br> 1";// i added these debug markers in my futile attempt to locate the problem. This one works properly
 require_once
('recaptchalib.php');
echo "<br> 2"; //this one works too
$privatekey
= "my private key"; $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 //in this case the returned page is totally blank
echo "<br> 3";//this one is not displayed
echo
<<<EOT <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Error</title> </head> <body bgcolor="WhiteSmoke"> EOT; switch ($_POST["lang"]) { case "en": echo <<<EOT <table width="100%" height="100%" border="0" cellspacing="10" align="center"> <tr> <td width="100" height="100" align="center" valign="middle"><h3>CAPTCHA failed ($resp->error)!</h3></td> </tr> </table> <meta HTTP-EQUIV='REFRESH' content='3; url=feedback_en.php'> </body> </html> EOT; break; //here go other possible $_POST['lang'] values which i removed from the sample since its irrelevant } } else { // Your code here to handle a successful verification //in this case the page returns totally blank either
echo "<br> 4";//this one isnt displayed either :( //here goes some db stuff //here goes sql injection check which is also skipped for this code //more db stuff switch ($_POST["lang"]) { case "en": echo <<<EOT <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Thank you!</title> <meta HTTP-EQUIV='REFRESH' content='3; url=feedback_en.php'> </head> <body bgcolor="WhiteSmoke"> <table width="100%" height="100%" border="0" cellspacing="10" align="center"> <tr> <td width="100" height="100" align="center" valign="middle"><h3>Thank you for the feedback, with your help this service will be better!</h3></td> </tr> </table> </body> </html> EOT; break; //and so on... } //end of switch //and we have nothing } ?>

Reply all
Reply to author
Forward
0 new messages