Here i have created a image less captcha. captcha is a one of the security for website form data and important. here i have generated a number captcha and ask to user type it in numbers. here we have used php class imagelessCaptcha.php to generate this task so see how to use that class and it working. below provide demo and you can download source code free. this captcha generate simple question like : what is Fifty and Thirty-two written as a number ?
below download complete source code to implement this captcah in your web projects.
PHP Code
<?php
session_start();
if (isset($_POST['submit']))
{
$number = floatval($_POST['number']);
if ($number != $_SESSION['correctNumber'])
{
$message = "<span class='errors'>The number you entered for the spam filter is incorrect.</span>";
}
else
{
$message = "<span class='success'>CAPTCHA Verified!!!</span>";
}
}
// include the class
include "imagelessCaptcha.php";
// implement imageless
$imgLess = new imagelessCaptcha();
$CaptchaPhrase = $imgLess->formPhrase();
$correctNumber = $imgLess->getInt();
$_SESSION['correctNumber'] = $correctNumber;
?>
in the above code i have include imagelessCaptcha class and get number and stor actual number in session to confirm the input.
<div class="main">'.$message.'<br>
<form action="index.php" method="post">
<label class="highlight"><span> '.$CaptchaPhrase.' :(spam filter)</span></label><br>
<input type="number" name="number" step="0.1" class="textInput" />
<input type="submit" value="Send" name="submit" class="submit" />
</form>
</div>
0 comments:
Post a Comment