Jump to content

If Captcha code is incorrect


helraizer

Recommended Posts

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.

 

captcha.php

 

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

Link to comment
Share on other sites

*shameless bumping* :P

 

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

Link to comment
Share on other sites

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. :P So there is now a 6 in 3480 or 1 in 580 chance for the bot to get it right on the analysis. :D (assuming it guesses, which it probably won't, but still)

Link to comment
Share on other sites

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 ;D

 

~ Chocopi

Link to comment
Share on other sites

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 ;D

 

~ 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

Link to comment
Share on other sites

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 ;D

 

~ Chocopi

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.