webguync Posted July 28, 2008 Share Posted July 28, 2008 I am using a php based form, that I didn't develop the original code for. There is a portion of the form where you identify images as a part of a CAPTCHA type recignition. What I want to do is randomize the images so that you can add eight different images, and they show up with two different images each time on refresh. here is the current code I am using: <table border="0"> <tr><td colspan="3">Security test. Please identify the pictures:</td></tr> <tr><td><img src="images/identiPIC_1.jpg" alt=""></td><td><img src="images/identiPIC_2.jpg" alt=""></td><td><img src="images/identiPIC_3.jpg" alt=""></td></tr> <tr><td> <select name="identiPIC_selected[1]"> <option value="">Click to identify</option> <option>Apple</option> <option>Cat</option> <option>Faucette</option> <option>Dog</option> <option>Flower</option> <option>Fork</option> <option>Hammer</option> <option>Key</option> <option>Ship</option> <option>Tree</option> </select></td><td> <select name="identiPIC_selected[2]"> <option value="">Click to identify</option> <option>Apple</option> <option>Cat</option> <option>Clock</option> <option>Dog</option> <option>Flower</option> <option>Fork</option> <option>Hammer</option> <option>Key</option> <option>Ship</option> <option>Tree</option> </select></td><td> <select name="identiPIC_selected[3]"> <option value="">Click to identify</option> <option>Apple</option> <option>Cat</option> <option>Clock</option> <option>Dog</option> <option>Flower</option> <option>Fork</option> <option>Hammer</option> <option>Key</option> <option>Ship</option> <option>Tree</option> </select></td></tr></table></td></tr> <tr><td> </td><td align="right"><input type="image" src="images/Send.jpg" value="Send"></td></tr> </table> and the PHP part: $identiPIC[1] = "Faucett"; $identiPIC[2] = "Keys"; $identiPIC[3] = "Lamp"; / Check identiPIC photo CAPTCHA. if($identiPIC_photo_CAPTCHA) { // Give an error if $_REQUEST['identiPIC_selected'] is not set, a bot might not send it. If set then give an error if it is not identical to the $identiPIC array. if(!isset($_REQUEST['identiPIC_selected'])){$errors[] = "You have failed to identify the pictures correctly. Please try again.";}else{if($_REQUEST['identiPIC_selected'] !== $identiPIC){$errors[] = "You have failed to identify the pictures correctly. Please try again.";} unset($_REQUEST['identiPIC_selected']);} } is there a way to add randomization? Quote Link to comment Share on other sites More sharing options...
Pyro Posted July 28, 2008 Share Posted July 28, 2008 you could set the value of the pictures to numbers, and make the php pick a number at random and show the picture that that number is appointed to, randomly. Quote Link to comment Share on other sites More sharing options...
webguync Posted July 28, 2008 Author Share Posted July 28, 2008 thanks for the reply. Can you post a small sample code, so that I can get an idea of what you are referring to? Quote Link to comment Share on other sites More sharing options...
Pyro Posted July 28, 2008 Share Posted July 28, 2008 sorry im not that advanced in php yet im still learning, i just have seen it before, im sorry there are sites that can give you it. sorry mate, but ive given you a lead. sorry ~Py Quote Link to comment 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.