|
|
Opslået på 12/05/2015 16.31.31
|
|
|
|

Renderingerne er som ovenfor:
QapTcha er et jQuery-trækkeligt captcha-system med jQuery-brugerflade!
QapTcha er et brugervenligt, simpelt og intuitivt captcha-system. Det kræver menneskelig adfærd, ikke at læse harddiskens tekst, og dette er et meget let jQuery-plugin.
For at fungere med iPhone og iPad er fil-jquery.ui.touch.js tilføjet i V2.5!
QapTcha fungerer PHP5.2 af ovenstående grunde til funktionen json_encode()!
Hvordan fungerer det? I DOM-konstruktion opretter QapTcha et skjult input med et tilfældigt navn "attribut fuld af tilfældige adgangskoder." Typisk udfylder en bot alle input i en formular, før den sendes ind.
Formålet med droppet er at tømme det tilfældige input og sætte en $_SESSION [qaptcha_key'] variabel med denne tilfældige værdi i Ajax.
Med PHP skal du bare tjekke, om det tilfældige input eksisterer og er tomt, hvis $_SESSION['qaptcha_key'] udfylder denne tilfældige værdi. I PHP-filer skal du gøre ting som:
- // 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']);
Kopier kode Implementation:
1. Først, inkluder CSS- og jQuery-filerne- <!-- 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>
Kopier kode 2. tilføj en DIV med klassen "qaptcha" i din formular
- <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>
Kopier kode 3. PHP kontrol, før du sender formularen
- // 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']);
Kopier kode 4. Kald nu Qaptcha-plugin'et
- <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>
Kopier kode
QapTcha-master.zip
(53.93 KB, Antal downloads: 13)
|
Tidligere:Åbn hjemmesiden, og løsningen Authorization Required-løsningen visesNæste:Løsningskort for implementering af CAPTCHA i asp.net
|