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&#039;] == 'send')) {

place the verification code:

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

Comment