Captcha code using core php
A captcha is a type of challenge-response test used in website as an attempt to ensure that the request is generated by a human being. There are basically 3 types of captcha first one and widely used is image captcha , second is mathematical captcha and last one is vice captcha.
Bellow are explanation of captcha. Using some of the features available in PHP for creating an image. This is very simple and basic tutorial and uses custom fonts for generating captcha image. And we know that captcha code is used to avoid spam/abuse or auto-submission.View Code PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?php session_start(); $code=rand(1000,9999); $_SESSION["code"]=$code; $im = imagecreatetruecolor(50, 24); $bg = imagecolorallocate($im, 22, 86, 165); //background color blue $fg = imagecolorallocate($im, 255, 255, 255);//text color white imagefill($im, 0, 0, $bg); imagestring($im, 5, 5, 5, $code, $fg); header("Cache-Control: no-cache, must-revalidate"); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?>