phpSensei Posted September 4, 2007 Share Posted September 4, 2007 I looked at no tutorials, and I tried to set a challenge for myself... I was wondering how everytime I refresh the page on a site, and the image of the verification code changes, and when validating the field where the code is inserted, The Field must match the image.... My problem is, if there is a much more simpler way of doing this... Images Directory /imgs/img.gif /imgs/img2.gif /imgs/img3.gif <?php $images = array("img","img2","img3"); shuffle($images); echo '<table width="22%" height="19" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="22%"><div align="center"><img src=" '.$images[0].' .gif" name="img" id="img"/></div></td> <td width="78%"><form name="form1" method="post" action=""> <label> <input type="text" name="code" id="code"> <input name="verification" type="hidden" id="verification" value="'.$images[0].'"> </label> </form> </td> </tr> </table> '; ?> VALIDATING THE FORM <?php $code = $_POST['code']; $imgtype = $_POST['verification']; if(($imgtype == "img")||($imgtype == "img2")||($imgtype == "img3")){ if($imgtype == "img"){ $verification = "123"; } elseif($imgtype == "img2"){ $verification = "246"; } else { $verification = "543"; } //////// End Code if($code <> $verification){ die("sorry, wrong code..."); } } else { die("code does not exist"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67940-is-this-image-verification-code-valid/ Share on other sites More sharing options...
AdRock Posted September 4, 2007 Share Posted September 4, 2007 Do you want a captcha image script becuase I have one Quote Link to comment https://forums.phpfreaks.com/topic/67940-is-this-image-verification-code-valid/#findComment-341549 Share on other sites More sharing options...
phpSensei Posted September 4, 2007 Author Share Posted September 4, 2007 whats wrong with my script? (Even though the same image might come up twice, but what are the chances of that since i will have around 30 of them, or more...). I also know what Captcha is... why don't people just use the same method as I do. Quote Link to comment https://forums.phpfreaks.com/topic/67940-is-this-image-verification-code-valid/#findComment-341580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.