01.
<html>
02.
<head>
03.
<title>Contoh Form</title>
04.
</head>
05.
<body>
06.
<h1>Contoh Form</h1>
07.
<form method=
"post"
action=
"submit.php"
>
08.
Masukkan Input Text <input type=
"text"
name=
"teks"
>
09.
<input type=
"submit"
name=
"submit"
value=
"Submit"
>
10.
</form>
11.
</body>
12.
</html>
1.
<?php
2.
$input
=
$_POST
[
'teks'
];
3.
echo
"Anda telah memasukkan input teks "
.
$input
;
4.
?>
Well ... now add a step with reCAPTCHA captcha script is as follows:
The first step, please do register first
Step into two, to register please click 'Use reCaptcha on Your Site'
Step three, please click the 'Sign Up'. If you already have a Google account just login.
The fourth step, fill in your website domain name in the box provided. If you want to install on multiple domains site, please unchecked 'Enable this key on all domains (global key)'.
Well ... once submitted, you will get a Public Key and Private Key. Please note carefully because both keys will be used to access its reCAPTCHA API.
Step five, download the file 'recaptchalib.php'. This file is the reCAPTCHA library. To download this file, please visit this site.
Step into a six, put the file 'recaptchalib.php' in the directory and the script form processing script formnya.
Step seven, paste this code in the form in order to display the captcha code of its
input.php
01.
<html>
02.
<head>
03.
<title>Contoh Form</title>
04.
</head>
05.
<body>
06.
<h1>Contoh Form</h1>
07.
<form method=
"post"
action=
"submit.php"
>
08.
Masukkan Input Text <input type=
"text"
name=
"teks"
><br>
09.
<?php
10.
require_once
(
'recaptchalib.php'
);
11.
$publickey
=
"..."
;
12.
echo
recaptcha_get_html(
$publickey
);
13.
?>
14.
<br>
15.
<input type=
"submit"
name=
"submit"
value=
"Submit"
>
16.
</form>
17.
</body>
18.
</html>
Fill in your Public Key on his $ publickey.
Step into the eight, we modif his little script follows submit.php
submit.php
01.
<?php
02.
require_once
(
'recaptchalib.php'
);
03.
$privatekey
=
"..."
;
04.
$resp
= recaptcha_check_answer (
$privatekey
,
05.
$_SERVER
[
"REMOTE_ADDR"
],
06.
$_POST
[
"recaptcha_challenge_field"
],
07.
$_POST
[
"recaptcha_response_field"
]);
08.
09.
if
(!
$resp
->is_valid)
10.
{
11.
// output jika kode captcha salah
12.
echo
"Maaf kode captcha yang Anda masukkan tidak valid"
;
13.
}
14.
else
15.
{
16.
// proses jika kode captcha benar
17.
$input
=
$_POST
[
'teks'
];
18.
echo
"Anda telah memasukkan input teks "
.
$input
;
19.
}
20.
?>
How To Install Anti-Spam with reCAPTCHA in PHP
4/
5
Oleh
Agus Prasetyo