Jump to content

Recommended Posts

I have a problem with my captcha script, the thing is it's showing in firefox, bt i obv. had to test it for ie(since most end users use this useless browser), and it doesnt show my captcha, i have to right click for it to show, has anyone else ever experienced this problem before, or do i have to post my code for someone to be able to help me, oh well what the heck i'll post it now

<?php
  ob_start();

  //Start the session
  session_start();

  //Load the Class
  require('./captcha.class.php');

  //Create a CAPTCHA
  $captcha = new captcha();

  //Store the String in a session
  $_SESSION['CAPTCHAString'] = $captcha->GetCaptchaString();

?>

CAPTCHA CLASS

<?php

  class captcha
  {

    var $Length;
    var $CaptchaString;
    var $ImageType;
    var $Font;
    var $CharWidth;

    function captcha ($length = 6, $type = 'png', $letter = '')
    {

      $this->Length    = $length;
      $this->ImageType = $type;
      $this->Font      = './hurryup.TTF';
      $this->CharWidth = 19;

      if ($letter == '')
      {

        $this->StringGen();

      }
      else
      {

        $this->Length        = strlen($letter);
        $this->CaptchaString = $letter;

      }

      $this->SendHeader();

      $this->MakeCaptcha();

    }

    function StringGen ()
    {

      $uppercase  = range('A', 'Z');
      $numeric    = range(0, 9);

      $CharPool   = array_merge($uppercase, $numeric);
      $PoolLength = count($CharPool) - 1;

      for ($i = 0; $i < $this->Length; $i++)
      {

        $this->CaptchaString .= $CharPool[mt_rand(0, $PoolLength)];

      }

    }

    function SendHeader ()
    {

      switch ($this->ImageType)
      {

        case 'jpeg': header('Content-type: image/jpeg'); break;
        case 'png':  header('Content-type: image/png');  break;
        default:     header('Content-type: image/png');  break;

      }

    }

    function MakeCaptcha ()
    {

      $imagelength = $this->Length * $this->CharWidth + 16;
      $imageheight = 35;

      $image       = imagecreate($imagelength, $imageheight);

      $bgcolor     = imagecolorallocate($image, 222, 222, 222);

      $stringcolor = imagecolorallocate($image, 0, 0, 0);
      $linecolor   = imagecolorallocate($image, 0, 0, 0);

      imagettftext($image, 25, 0, 8, 22,
                   $stringcolor,
                   $this->Font,
                   $this->CaptchaString);

      switch ($this->ImageType)
      {

        case 'jpeg': imagejpeg($image); break;
        case 'png':  imagepng($image);  break;
        default:     imagepng($image);  break;

      }

    }

    function GetCaptchaString ()
    {

      return $this->CaptchaString;

    }

  }

?>

AND HERES MY CODE TO USE IT

$form = "<img src=\"./captcha.php\" alt=\"Security code\" />";

and they're all in the same directory

Link to comment
https://forums.phpfreaks.com/topic/54990-captcha-not-working-in-ie/
Share on other sites

I recommend against using image CAPTCHAs. My company recently asked my to research the Section 508 standards. I found some interesting information that showed the results of studies done. In 1998, 7-10% of people that had some type of disability used the internet. In 2001, that number increased to ~38%. It doesn't seem like a lot, but you can accomplish the same concept with a simple text input.

 

Just giving my $0.02 (no disrespect).

 

I was using an image CAPTCHA on my site but replaced it with a text input. My code didn't look like yours at all, but if you're interested in looking at it, PM me and I'll try to dig it up.

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.