captcha

Simple captcha for oscommerce contact form

Embed the captcha image by calling a php script in "contact_us.php":

<input type="text" name="verify" />
<img src="/image.php" width="60" height="20" alt="Please enter the values from this image" />

Edit contact_us.php file and exactly after the below line:

  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {

place the verification code:

        // Captcha check
        $t = trim($HTTP_POST_VARS['verify']);
        if ($t == "") {
                $captcha_error = "Enter the verification code!";
                $error = true;
                $messageStack->add('contact', $captcha_error);
        } else if (trim($_SESSION["thecode"]) == "") {
                $captcha_error = "No verification code generated!";
                $error = true;
                $messageStack->add('contact', $captcha_error);
        } else if ($_SESSION["thecode"] != strtoupper($t)) {
                $captcha_error = "Invalid verification code!";
                $error = true;
                $messageStack->add('contact', $captcha_error);
        }
        else
        { // End Captcha Check

Syndicate content
Comment