I am trying to create a contact form with captcha, but captcha not working. I created captcha image by this in another file and stored value in session:
//I already have start session and the beginning of file
header('Content-Type: image/jpeg');// defining the image type to be shown in browser widow
imagejpeg($image);//showing the image
imagedestroy($image);//destroying the image instance
$_SESSION['image_code'] = $code;
and on the form side I am comparing it by:
if(empty($_SESSION['image_code'] ) ||
strcasecmp($_SESSION['image_code'], $_POST['posted_captcha']) != 0)
{
//Note: the captcha code is compared case insensitively.
//to overcome this i can use
// strcmp()
$errors .= "n The captcha code does not match!";
}
may be my plugin not getting session value for image. I tried to add session start at wp-config.php, wp-load.php and plugins file but the captcha stayed same. Help would be appreciate thanks 🙂