Add ReCaptcha to static HTML with server-side PHP question

528 views
Skip to first unread message

Aram

unread,
Jan 13, 2009, 5:56:21 PM1/13/09
to reCAPTCHA
So I want to add the recaptcha to a static HTML page with the
validation on a server page, but I can't track down what HTML tags to
use to display the ReCaptcha. Here is something like what I want to
do:

form.html

<form action="something.php" method="post">
<input type="text" value="name" name="someones_name" />

<!-- Insert ReCaptcha HTML code here -->
</form>



something.php

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

if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it
again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
?>


So what can I put in the HTML section in order to display the
ReCaptcha. I would change the page to a php page, but due to the site
I am building I am forced to keep it a static HTML page and thus need
a static way to create the ReCaptcha.

Thanks much!

Ast Derek

unread,
Jan 14, 2009, 7:06:48 PM1/14/09
to reCAPTCHA
Just insert the <iframe> ... </iframe> section from the client API:

<iframe src="http://api.recaptcha.net/noscript?k=$publickey"
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">
Reply all
Reply to author
Forward
0 new messages