Renderingnya seperti di atas:
QapTcha adalah sistem captcha jQuery yang dapat diseret dengan UI jQuery!
QapTcha adalah sistem captcha yang mudah digunakan, sederhana, dan intuitif. Ini membutuhkan perilaku manusia, tidak membaca teks hard drive, dan ini adalah plugin jQuery yang sangat ringan.
Untuk bekerja dengan iPhone dan iPad, jquery.ui.touch.js file telah ditambahkan di V2.5!
QapTcha bekerja PHP5.2 karena alasan di atas untuk fungsi json_encode()!
Bagaimana cara kerjanya? Dalam konstruksi DOM, QapTcha membuat input tersembunyi dengan nama acak "atribut penuh kata sandi acak." Biasanya, bot mengisi semua input ke dalam formulir sebelum mengirim formulir.
Tujuan dari penurunan adalah untuk mengosongkan input acak dan mengatur variabel $_SESSION [qaptcha_key'] dengan nilai acak ini di Ajax.
Dengan PHP, periksa saja apakah input acak ada dan kosong, jika $_SESSION['qaptcha_key'] mengisi nilai acak ini. Dalam file PHP, Anda harus melakukan hal-hal seperti:
- // check if $_SESSION['qaptcha_key'] created with AJAX exists
- if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
- {
- $myVar = $_SESSION['qaptcha_key'];
-
- // check if the random input created exists and is empty
- if(isset($_POST[''.$myVar.'']) && empty($_POST[''.$myVar.'']))
- {
- //mail can be sent
- }
- else
- {
- //mail can not be sent
- }
- }
- unset($_SESSION['qaptcha_key']);
Salin kode Implementation:
1. Pertama, sertakan file CSS & jQuery- <!-- include CSS & JS files -->
- <!-- CSS file -->
- <link rel="stylesheet" type="text/css" href="QapTcha.jquery.css" media="screen" />
-
- <!-- jQuery files -->
- <scrip去掉t type="text/javascrip去掉t" src="jquery.js"></scrip去掉t>
- <scrip去掉t type="text/javascrip去掉t" src="jquery-ui.js"></scrip去掉t>
- <scrip去掉t type="text/javascrip去掉t" src="jquery.ui.touch.js"></scrip去掉t>
- <scrip去掉t type="text/javascrip去掉t" src="QapTcha.jquery.js"></scrip去掉t>
Salin kode 2. tambahkan DIV dengan kelas "qaptcha" ke dalam formulir Anda
- <form method="post" action="">
- <fieldset>
- <label>First Name</label> <input type="text" name="firstname" />
- <label>Last Name</label> <input type="text" name="lastname" />
- <div class="clr"></div>
-
- <!-- Add this line in your form -->
- <div class="QapTcha"></div>
-
- <input type="submit" name="submit" value="Submit form" />
- </fieldset>
- </form>
Salin kode 3. PHP kontrol sebelum mengirim formulir
- // check if $_SESSION['qaptcha_key'] created with AJAX exists
- if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
- {
- $myVar = $_SESSION['qaptcha_key'];
-
- // check if the random input created exists and is empty
- if(isset($_POST[''.$myVar.'']) && empty($_POST[''.$myVar.'']))
- {
- //mail can be sent
- }
- else
- {
- //mail can not be sent
- }
- }
- unset($_SESSION['qaptcha_key']);
Salin kode 4. Sekarang, panggil plugin Qaptcha
- <scrip去掉t type="text/javascrip去掉t">
- $(document).ready(function(){
- // Simple call
- $('.QapTcha').QapTcha();
-
- // More complex call
- $('.QapTcha').QapTcha({
- autoSubmit : true,
- autoRevert : true,
- PHPfile : 'path_to_my_php_file/Qaptcha.jquery.php'
- });
- });
- </scrip去掉t>
Salin kode
QapTcha-master.zip
(53.93 KB, Jumlah unduhan: 13)
|