brmcdani Posted November 12, 2009 Share Posted November 12, 2009 I recently wrote a PHP script to add to my registration page that allows for human verification by pulling random strings out of an array. I am having trouble making my if statement work to where it checks the array before approving the user's registration. Here is what I have so far: $verification = protect($_POST['verification']); if($verification != $rand){ echo "Sorry but the number verification you entered was not correct"; } $rand = array("asfd7", "ghdg3", "kfdr6", "sdas3", "hdsa6", "gdsd9", "ijko5"); $keys = array_rand($rand, 1); echo "Verification letters: "; echo $rand[$keys]; Can someone please point me in the right direction? Thanks Quote Link to comment Share on other sites More sharing options...
darkvengance Posted November 12, 2009 Share Posted November 12, 2009 You should check out the in_array() function...but here is what you are trying to do...I think: $verification = protect($_POST['verification']); $rand = array("asfd7", "ghdg3", "kfdr6", "sdas3", "hdsa6", "gdsd9", "ijko5"); if(!in_array($verification,$rand)){ echo "Sorry but the number verification you entered was not correct"; } $keys = array_rand($rand, 1); echo "Verification letters: "; echo $rand[$keys]; Quote Link to comment Share on other sites More sharing options...
brmcdani Posted November 12, 2009 Author Share Posted November 12, 2009 Ok that worked great, thanks! I was in the middle of looking at that in the manual when I got your post. What would I do if I want to end the registration if it is not in the array? Even if the verification is wrong it still registers the user? Any ideas? Quote Link to comment Share on other sites More sharing options...
brmcdani Posted November 12, 2009 Author Share Posted November 12, 2009 Nevermind got it! 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.