helraizer Posted December 10, 2007 Share Posted December 10, 2007 Hi folks, I made an advanced captcha image yesterday, which will be easy for a human user to read but very difficult for an image analyzer, because it consists of 3 layers (three different images); 5 different captcha codes: one on the middle layer, one on the bottom and three on the top; and lots of random background distortion on each layer. The user has to enter the code that is in black. (it's easier to see on my website, since it has a black background). But anywho, to the question at hand. This captcha system is for a commenting system to stop spam, to an extent. The user can view the comments if they just go onto it, if they want to write a comment the captcha has to be correct, if the captcha is incorrect the form doesn't submit. How would I get to so that on that redirect (when the captcha is wrong) it says on the page, next to the captcha image something like "The code was incorrect, please try again". Hope that makes sense, Sam Quote Link to comment Share on other sites More sharing options...
helraizer Posted December 10, 2007 Author Share Posted December 10, 2007 *shameless bumping* I'm not sure I explained myself very well. So I'll try again. =) On some sites, if you enter the captcha code (or one of the form fields) wrong, or not at all, it does not submit the form and it comes up with with usually a red asterisk with message, like: *You must enter the code, or similar. How would I do this, since currently on the page that the form submits to I just have the code if(isset($_POST['submit']) && ($_SESSION['security_code'] !== $_POST['security_code']) && (!empty($_SESSION['security_code']))) { header("Location: http://www.helraizer.co.uk/count/index.php5"); } What would be the answer, do you think? Sam Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 10, 2007 Share Posted December 10, 2007 I don't know how to help you, but I really like your capcha image. I'm colorblind (100%) and have a hell of a time with them most of the time. Even with how busy yours is, it's easy for me to read =P Quote Link to comment Share on other sites More sharing options...
helraizer Posted December 10, 2007 Author Share Posted December 10, 2007 I don't know how to help you, but I really like your capcha image. I'm colorblind (100%) and have a hell of a time with them most of the time. Even with how busy yours is, it's easy for me to read =P Thanks. =P Yeah, it's a bit busy.. there are now still 3 layers but within those three, there are now 20 codes. So there is now a 6 in 3480 or 1 in 580 chance for the bot to get it right on the analysis. (assuming it guesses, which it probably won't, but still) Quote Link to comment Share on other sites More sharing options...
chocopi Posted December 10, 2007 Share Posted December 10, 2007 doesnt the code you showed a few posts back work ? if($_POST) { if($_POST['captcha'] != $_SESSION['captcha']) { die("Incorrect Code"); } else { echo "Captcha Correct"; } } All you have to do is change the die() to a redirect where the page says "incorrect capthca" or just show the same page and show the error message. Hope that help ~ Chocopi Quote Link to comment Share on other sites More sharing options...
helraizer Posted December 10, 2007 Author Share Posted December 10, 2007 doesnt the code you showed a few posts back work ? if($_POST) { if($_POST['captcha'] != $_SESSION['captcha']) { die("Incorrect Code"); } else { echo "Captcha Correct"; } } All you have to do is change the die() to a redirect where the page says "incorrect capthca" or just show the same page and show the error message. Hope that help ~ Chocopi Hey, thanks for the reply. Yeah, my code that I posted does redirect but there is then no error message, because it just goes back to the first page. Therefore the user might not know why they've been redirected. So I shall try your code. Sam Quote Link to comment Share on other sites More sharing options...
chocopi Posted December 16, 2007 Share Posted December 16, 2007 what you could do on the redirect is use a $_GET to display the error if($_POST) { if($_POST['captcha'] != $_SESSION['captcha']) { header("Location: yourpage.php?captcha=error"); } else { echo "Captcha Correct"; } } then on yourpage.php have some code somewhere that will display the error if($_GET['captcha'] == 'error') { echo "Your captcha was incorrect"; } something like that should work Hope it Helps ~ Chocopi 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.