i’d like some help please.
I’m having a contact form in which i’d like to add some captcha, with NO GD Library. I’ve added some images as a guide but there are static right now. What i’m trying to do is to output in a loop the images that will match with the code (random number) in the hidden field, for example if the random number is “18301” will display the appropriate images for each number, here is my code so far:
<label for="captcha">Type the code you see (*):<br />
<?php (do a loop here){ ?>
<img src="images/0<?php echo $num; ?>.gif" width="18" height="30" />
<?php } ?>
<img src="images/00.gif" width="18" height="30" />
<img src="images/01.gif" width="18" height="30" />
<img src="images/08.gif" width="18" height="30" />
<img src="images/03.gif" width="18" height="30" />
<img src="images/00.gif" width="18" height="30" />
<img src="images/01.gif" width="19" height="30" /> =</label>
<span id="spryCaptcha">
<input type="text" name="captcha" id="captcha" tabindex="70" />
<input name="hiddenCode" type="hidden" value="<?php echo rand(000000,999999); ?>"/>
How can i make this works so that the correct images will appear each time and checkes the user’s input will match to the code he/she sees each time??
you should initialize the random number before the loop:
but your should save that in a session and check afterwards (because an hidden field is 0 security):
call
session_start()on top of your pageand check on next page for your
$_POST['captcha']against$_SESSION['captcha']still, this is 0 security as image names can be read.