Getting Started

Start using CTection WebCaptcha right away!

Step 1. Client Side Elements


Include the WebCaptcha Client-side JavaScript file and insert a Captcha Element in your form. The script will then automatically insert a captcha image and input field into the ctec_captcha div. User input for the captcha is provided via parameter "ctec_captcha_txt_{x}" where {x} is the number of the captcha element, starting at 0.
<!DOCTYPE html>
<html>
 <head>
  <title>CTection WebCaptcha Test</title>
 </head>
 <body>
  <form action="process.php" method="post">
   <div class="ctec_captcha"></div>
   <button type="submit">Go!</button>
  </form>
 </body>
 <script src="https://ctection.com/cdn/captcha.js"></script>
</html>

Step 2. Server Side Parsing


Contact our API to check the validity of the code entered in the form. You can also use one of our libraries to make checking captcha validity easier. The parameter names for the captcha fields are "ctec_captcha_txt_{x}" and "ctec_captcha_vc_{x}" for the user input and captcha id respectively. A URI of the page containing the captcha has to be passed to prevent cross-site CAPTCHAs.
<?PHP
if(isset($_POST["ctec_captcha_vc_0"])){
 $api_ret = json_decode(file_get_contents("https://ctection.com/api/v1/check_captcha.php?c=".urlencode($_POST["ctec_captcha_txt_0"])."&uid=".urlencode($_POST["ctec_captcha_vc_0"])."&uri=".urlencode("ctection.com")),true);
 if(isset($api_ret["valid"])){
  if($api_ret["valid"]){
   echo "Captcha Valid";
  }else{
   echo "Captcha Invalid";
  }
 }else{
  print_r($api_ret);
 }
}
?>
PHP Example Code