|
-
Dec 29th, 2008, 11:34 AM
#1
Thread Starter
Fanatic Member
[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....
-
Dec 29th, 2008, 11:55 AM
#2
-
Dec 29th, 2008, 12:06 PM
#3
Thread Starter
Fanatic Member
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>
Last edited by mojo69; Dec 29th, 2008 at 12:09 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|