How to add random numeric value captcha without images in a script. How to make it work
please provide code.
please provide code.
<?php
function mathcaptcha()
{
$x=rand(1,9);
$y=rand(1,9);
$_SESSION['result'] = $x + $y;
$math = $x.' + '.$y.' = ';
$math .= "<input size="30" maxlength="20" type="text" name="captcha" />";
return $math;
}
function checkcaptcha()
{
$result = false;
$check = isset($_SESSION['result']) ? $_SESSION['result'] : 'none';
unset($_SESSION['result']);
if(is_numeric($check) && is_numeric($_POST['captcha']) && ($check == $_POST['captcha']))
{
$result = true;
}
return $result;
}
?>
Comment