please am having image captcha problem. I uploaded some images on my site to be used as captcha. the name i used to save each image is the word on it. for example, on the image which i saved with the name 'FOOD' has the word FOOD written on it. So the guest needs to write the name on the image into a field named 'capname'. This is how i randomly select the images;
Code: Select all
<?php
$imglist='';
$img_folder = "captcha/"; #Don't forget to put / in the end#
mt_srand((double)microtime()*1000);
//using the directory class
$imgs = dir($img_folder);
//reads all the files from the folder and checks if they are images and then ads them to a list
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
$picname= $image;
$imgname=$picname.'png'
?>Code: Select all
if($capname != $imgname)
echo "<span class='style3'>You've entered wrong word in the Picture, retry.</span><br>";what can i do. or do you have any other way of echoing out the images and verifying them.