Home > Article > Backend Development > Using Captcha in Cakephp to implement more secure verification codes
First, you can use the following program to get the verification code image. Note that the session variable is adjusted when the program generates the image.
getImage.php
include('kcaptcha.php');
session_start();
$captcha = new KCAPTCHA();
$_SESSION['captcha_keystring'] = $captcha->getKeyString();
?>
Next, call the verification code image through the following form, and verify whether the user input matches the verification code image value.
index.php
session_start();
$true_key_string = $_SESSION['captcha_keystring'];
echo $true_key_string;
?>
< html>
if(isset($_SESSION['captcha_keystring']) && $true_key_string == $_POST['keystring'])
{
echo "Correct";
}else
{
echo "Wrong";
}
?>