Register

This is an error
This is an error

Captcha Billiard


How to use:


Include this needed css file ( style-captcha.css ) in your head tag:

<link rel="stylesheet" type="text/css" href="PATH/TO/STYLE/FILE/style/style-captcha.css" />

Replace this css file ( style-captcha-rtl.css ) with style-captcha.css if your web page is RTL:

<link rel="stylesheet" type="text/css" href="PATH/TO/STYLE/FILE/style/style-captcha-rtl.css">

Also include these JS files:

<script type="text/javascript" src="PATH/TO/JS/FILE/src/js/jquery-1.9.1.js"></script> <!-- Required -->
<script type="text/javascript" src="PATH/TO/JS/FILE/src/js/jquery-ui.js"></script> <!-- Required -->
<script type="text/javascript" src="PATH/TO/JS/FILE/jquery-captcha-1.0.0.js"></script> <!-- Plugin -->

Choose a tag with a unique ID in your form or wherever you like to use the captcha:
As you see in the following example we gave a div inside the form the id of "captchaIdBilliard"
We will use this id in the next step.

<form action="your_php_file.php" class="register active" method="post">
    <h3>Register</h3>
    <div class="column">
        <label>First Name:</label>
        <input type="text" name="fname" id="fname" value="John"/>
    </div>
    <div class="column">
        <label>Last Name:</label>
        <input type="text" id="lname" value="Doe"/>
    </div>
    <div class="bottom">
        <div id="captchaIdBilliard"></div> <!-- Captcha code goes here -->
        <div class="clear"></div>
        <button type="button" class="btn" name="register" >Register</button>
        <button type="button" class="btn" onclick="$('#captchaIdBilliard').CaptchaReset(); /* for refreshing captcha*/" >Refresh</button>
    </div>
</form>

Call captcha code:
Now you should enter the ID that we mentioned above like the following line in your body.
Then you should assign a name ( id ) for the first argument. For example; NameOfYourAnswerHiddenInput_Billiard
This will be the hidden input id which the plugin makes and puts the captcha asnwer in it.
NOTE: The first argument ( required ) will be also used in the next step
The second argument ( required ) is the address of the captchaBuilder folder which is placed in this item
The third argument ( optional ) is the Option for the captcha which will be described in the next steps

<script type="text/javascript" >
    $("#captchaIdBilliard").CaptchaBilliard("NameOfYourAnswerHiddenInput_Billiard","PATH/TO/CAPTCHA/BUILDER/FOLDER/captchaBuilder", options);
</script>

In your php file to which the form data will be sent ( "your_php_file.php"):
In order to check whether the captcha answer is true or false you should firstly include the session_start() method at the beginning of codes
Then include captchaSecure.php file which is in captchaBuilder folder and initialize the captchaSecure class
There is a public function named check() in captchaSecure class that has an argument. This argument is the exact input hidden value we had given in previous steps

<?php
session_start(); /* You must start session. This is Required for checking captcha */
if(isset($_POST['register']))
{
    require_once 'PATH/TO/CAPTCHA/BUILDER/FOLDER/captchaBuilder/captchaSecure.php';
    $secret = new captchaSecure();
    if($secret->check($_POST['NameOfYourAnswerHiddenInput_Billiard']))
    {
        // If captcha is true
        // Write your surce code
        echo 'Hello '.$_POST['fname'].' '.$_POST['lname'];
    }
    else
    {
        echo "Captcha is false";
    }
}
else
{
    echo "Form is not sent";
}
?>

Options

Remember the third argument we talked above. You can set these below parameters in options argument otherwise the default will be set as your captcha options.
Please also see the below example.

Params Type Example Description Default
size String small small, medium or large medium
rtl Boolean false If your web page is RTL this must be true false
ondownMove Function name_of_your_function When the ball falls in the hole this function will be called null