| ขั้นตอนสำหรับ PHP Webmaster 1. เตรียม Server ที่รองรับ PHP
 2. Signup recaptcha จาก google
 3. คัดลอก public & private key มาใช้ใน code
 4. Dowload recaptchalib.php จาก google
 5. ปรับ และทดสอบ code นี้
 6. ปรับ input ให้เป็นตามที่ท่านต้องการ
 
 
  แนวคิดการใช้ captcha ป้องกัน spam
 | 
<?php
if (!isset($_POST["d"])) { ?>
<form action="" method="post"><input name="d" /><input type="submit" />
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=TuMSAAAAAAAA">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=TuMSAAAAAAAA"
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>
</form>
<?php 
} else {
require_once('recaptchalib.php');
$publickey = "TuMSAAAAAAAA";
$privatekey = "AAAadfSDFasdfddDSOUPaE";
# 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"]) {
  $ra = $_SERVER["REMOTE_ADDR"];
  $pcf = $_POST["recaptcha_challenge_field"];
  $prf = $_POST["recaptcha_response_field"];
  $resp = recaptcha_check_answer ($privatekey, $ra, $pcf, $prf);
  if ($resp->is_valid) echo $_POST["d"]; else echo "fail";
}
}
?> |