kellz Posted November 8, 2007 Share Posted November 8, 2007 I was attempting (AGAIN) to make 1 of those things that stops bots and I think apart from it not working it's a little better lol , well, it half works^^ <?php session_start(); ?> <?php if (isset($_SESSION['correct'])) $correct = $_SESSION['correct']; if (isset($_POST[$correct])) { echo 'you were right!'; } else { echo '...might you be a bot?'; } if ($directory = opendir('pics')) { while(($filename = readdir($directory)) !== false) { if (stristr($filename, ".gif")) { $f_arr[] = $filename; } } closedir($directory); } shuffle($f_arr); $_SESSION['correct'] = substr($f_arr[0], 0, strpos($f_arr[0],'.')); echo '<img src="pics/'.$f_arr[0].'" width="32" height="32" /><br>'; shuffle($f_arr); echo '<form id="form1" name="form1" method="post" action="">'; foreach ($f_arr as $img) { echo '<label>'.substr($img, 0, strpos($img,'.')). '</label><input name="'.substr($img, 0, strpos($img,'.')).'" type="radio" value="radiobutton" />'; } echo '<input type="submit" name="Submit" value="Submit" /></form>'; ?> it keeps saying "...might you be a bot?" before the form is even submit! is it true that PHP can become posessed? so yea.. I run out of idea's, as far as I can see it should be right! :'( I spend all day reading and it only gets me more problems!! ps: please Please PLEASE dont write a new 1 or edit it all to much, I hate getting everything solved for me.. just a little bit is ok to show me where i went wrong.. thanks you! Quote Link to comment Share on other sites More sharing options...
revraz Posted November 8, 2007 Share Posted November 8, 2007 I don't see where you are even checking Submit: if (isset($_SESSION['correct'])) $correct = $_SESSION['correct']; if (isset($_POST[$correct])) { echo 'you were right!'; } else { echo '...might you be a bot?'; } The first if isset is probably false, so it goes to the second if isset which is false so it echo's Might you be a bot? You need code to check if Submit is set. Quote Link to comment Share on other sites More sharing options...
kellz Posted November 8, 2007 Author Share Posted November 8, 2007 i thought so too and before i posted i tried this: if (isset($_POST['Submit']) && isset($_SESSION['correct'])) $correct = $_SESSION['correct']; if (isset($_POST[$correct])) { echo 'you were right!'; } else { echo '...might you be a bot?'; } } after I posted I tried it like this: if (isset($_POST['Submit'])) { if (isset($_SESSION['correct'])) $correct = $_SESSION['correct']; if (isset($_POST[$correct])) { echo 'you were right!'; } else { echo '...might you be a bot?'; } } And that decided to work... not sure what the big deal was between the both methods.. thanks! 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.