Help Needed for captcha Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Elven6
Forum Newbie
Posts: 5
Joined: Fri Dec 18, 2009 12:58 pm

Help Needed for captcha Script

Post by Elven6 »

Hello,

I am working on a script where reCAPTCHA or a similar form of CAPTCHA will be used, for the sake of this example I will talk about reCAPTCHA. I wanted to know how I could have the reCAPTCHA script store a value upon correctly entering a code that will be used by a different script to allow on to proceed?

A snippet of the reCAPTCHA code which will be located in a file called recaptcha.php.

Code: Select all

if ($resp->is_valid) {
   [b]$captcha = "1";
    # in a real application, you should send an email, create an account, etc[/b]
  } else {
    # set the error code so that we can display it. You could also use
    # die ("reCAPTCHA failed"), but using the error message is
    # more user friendly
    $error = $resp->error;
  }
}

I bolded the part of interest, how would I be able to use a variable like

Code: Select all

$captcha = "1";
In a completely different file that is called login.php to allow one to login if the captcha is correct? The value would only be needed for that session of course. I want to use this method because the captcha script might be used in multiple locations so I figure this route would be easier and allow for quicker modifications than have the script called each time in different files for instance.

Any help would be appreciated, thanks in advance!
Post Reply