-
[RESOLVED] Captcha ?
I am looking at reCAPTCHA. When I try to view the sample code the page is not rendered correctly.
PHP Code:
<html>
<body>
<form action="" method="post">
<?php
require_once('recaptchalib.php');
// Get a key from http://recaptcha.net/api/getkey
$publickey = "";
$privatekey = "";
# 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);
?>
<br/>
<input type="submit" value="submit" />
</form>
</body>
</html>
everything in the code after the > in $resp-> is_valid shows on the page.
Any hints as to what I am doing wrong....
-
Re: Captcha ?
What do you mean exactly? It prints the php code in the webbrowser?
One mistake I see is that you haven't put the $publickey and $privatekey values (unless you removed them to post here).
-
Re: Captcha ?
I figured that one out. I did not have the javascript on the page to enable the captcha.
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<>">
</script>
I have another problem with the page though.
The submit button does not appear on the page??
Code:
<tr>
<td>
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<>">
</script>
<?php
require_once('recaptchalib.php');
// Get a key from http://recaptcha.net/api/getkey
$publickey = "";
$privatekey = "";
# 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);
?>
</td>
<td><input type="submit" value="Submit Request" /></td>
<!-- <td width=500><input type="submit" value="Submit Request" /></td>-->
</tr>