This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15590|Reply: 1

PHP How to Add Sliding Captcha Tutorial

[Copy link]
Posted on 5/12/2015 4:31:31 PM | | | |


The renderings are as above:

QapTcha is a jQuery draggable captcha system with jQuery UI!


QapTcha is an easy-to-use, simple and intuitive captcha system.
It requires human behavior, not reading the text of the hard drive, and this is a very lightweight jQuery plugin.


To work with iPhone and iPad, file jquery.ui.touch.js has been added in V2.5!


QapTcha works PHP5.2 for the above reasons for the function json_encode()!


How does it work?
In DOM construction, QapTcha creates a hidden input with a random name "attribut full of random passwords."
Typically, a bot fills in all inputs into a form before sending the form.


The purpose of the drop is to empty the random input and set a $_SESSION [qaptcha_key'] variable with this random value in Ajax.


With PHP, just check if the random input exists and is empty, if $_SESSION['qaptcha_key'] populates this random value.
In PHP files, you have to do things like:


  1. // check if $_SESSION['qaptcha_key'] created with AJAX exists
  2. if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
  3. {
  4.   $myVar = $_SESSION['qaptcha_key'];
  5.   
  6. // check if the random input created exists and is empty
  7.   if(isset($_POST[''.$myVar.'']) && empty($_POST[''.$myVar.'']))
  8.   {
  9.     //mail can be sent
  10.   }
  11.   else
  12.   {
  13.     //mail can not be sent
  14.   }
  15. }
  16. unset($_SESSION['qaptcha_key']);
Copy code
Implementation:
1. First, include the CSS & jQuery files
  1. <!-- include CSS & JS files -->
  2. <!-- CSS file -->
  3. <link rel="stylesheet" type="text/css" href="QapTcha.jquery.css" media="screen" />

  4. <!-- jQuery files -->
  5. <scrip去掉t type="text/javascrip去掉t" src="jquery.js"></scrip去掉t>
  6. <scrip去掉t type="text/javascrip去掉t" src="jquery-ui.js"></scrip去掉t>
  7. <scrip去掉t type="text/javascrip去掉t" src="jquery.ui.touch.js"></scrip去掉t>
  8. <scrip去掉t type="text/javascrip去掉t" src="QapTcha.jquery.js"></scrip去掉t>
Copy code
2. add a DIV with the class "qaptcha" into your form
  1. <form method="post" action="">
  2.   <fieldset>
  3.     <label>First Name</label> <input type="text" name="firstname" />
  4.     <label>Last Name</label> <input type="text" name="lastname" />
  5.     <div class="clr"></div>

  6.     <!-- Add this line in your form -->
  7.     <div class="QapTcha"></div>

  8.     <input type="submit" name="submit" value="Submit form" />
  9.   </fieldset>
  10. </form>
Copy code
3. PHP control before sending the form
  1. // check if $_SESSION['qaptcha_key'] created with AJAX exists
  2. if(isset($_SESSION['qaptcha_key']) && !empty($_SESSION['qaptcha_key']))
  3. {
  4.   $myVar = $_SESSION['qaptcha_key'];

  5.   // check if the random input created exists and is empty
  6.   if(isset($_POST[''.$myVar.'']) && empty($_POST[''.$myVar.'']))
  7.   {
  8.     //mail can be sent
  9.   }
  10.   else
  11.   {
  12.     //mail can not be sent
  13.   }
  14. }
  15. unset($_SESSION['qaptcha_key']);
Copy code
4. Now, call Qaptcha plugin
  1. <scrip去掉t type="text/javascrip去掉t">
  2.   $(document).ready(function(){
  3.     // Simple call
  4.     $('.QapTcha').QapTcha();
  5.    
  6.     // More complex call
  7.     $('.QapTcha').QapTcha({
  8.       autoSubmit : true,
  9.       autoRevert : true,
  10.       PHPfile : 'path_to_my_php_file/Qaptcha.jquery.php'
  11.     });
  12.   });
  13. </scrip去掉t>
Copy code


QapTcha-master.zip (53.93 KB, Number of downloads: 13)






Previous:Open the website page and the Authorization Required solution appears
Next:Solution brief for CAPTCHA implementation in asp.net
Posted on 5/14/2015 9:19:37 PM |
Use Qaptcha as a verification code in the ASP.NET with the source code of the finished product
http://www.itsvse.com/forum.php?mod=viewthread&tid=1960
(Source: Wuhan Software Engineering Vocational College)
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com