Image Verification form

Discussion in 'Web Design and Development' started by janitorC7, Apr 3, 2007.

  1. janitorC7 macrumors 6502a

    janitorC7

    Joined:
    Feb 10, 2006
    Location:
    North Hollywood, CA
    #1
  2. ChicoWeb macrumors 65816

    ChicoWeb

    Joined:
    Aug 16, 2004
    Location:
    California
    #2
    Thats one hell of a form. I would also put some required fields on that thing!!
     
  3. rogersmj macrumors 68020

    rogersmj

    Joined:
    Sep 10, 2006
    Location:
    Indianapolis, IN
    #3
    What you're looking for is known as a "captcha". Search for captcha libraries/plugins/classes that are compatible with whatever language you're using for your site.
     
  4. Nicolasdec macrumors 65816

    Nicolasdec

    Joined:
    Dec 7, 2006
    Location:
    São Paulo
  5. janitorC7 thread starter macrumors 6502a

    janitorC7

    Joined:
    Feb 10, 2006
    Location:
    North Hollywood, CA
    #5
    ummm, wow.. a lot, proably arround 200 in the last week...

    thanks guys
     
  6. Nicolasdec macrumors 65816

    Nicolasdec

    Joined:
    Dec 7, 2006
    Location:
    São Paulo
    #6
    WOW, are they most spambots?
     
  7. janitorC7 thread starter macrumors 6502a

    janitorC7

    Joined:
    Feb 10, 2006
    Location:
    North Hollywood, CA
    #7
    I think they all are
     
  8. jackbenimble4 macrumors member

    Joined:
    Jan 7, 2007
    Location:
    Providence, RI
    #8
    I know I have a more advanced version of this script somewhere but can't find it so here's a more primitive one I built. You can save this as a php file, and then link to the php file as an image like <img src="thephpfile.php" />. It uses the GD Library to create an image with random characters of random colors. I used to have alternating backgrounds, as well as titled letters. This should probably help your problem somewhat though. Anyways, this script also sets a session variable 'imageVeriChars' to a hash of the letters that were on the image. That way when they submit the form, you can apply the md5 function to what they entered and compare it to what's in $_SESSION['imageVeriChars'].

    Oh and './images/verificationimgbg.png' needs to be replaced with the path to a background .png image.

    It'll take some fiddling to get to work, but it might be of some help to you.


    PHP:
    <?php 

    $width 
    80;
    $height 40;
    $image ImageCreate($width,$height);
    $color ImageColorAllocate($image,41,41,41);


    srand((double)microtime()*1000000); 

    $string md5(rand(0,9999));

    $string substr($string,17,5);

    $bg imagecreatefrompng("./images/verificationimgbg.png");

    imagesettile($image$bg);

    ImageFilledRectangle($image,0,0,$width$height,IMG_COLOR_TILED);

    $textcolor ImageColorAllocate($image,153,153,153);

    $xposition rand(1,32);

    $yposition rand(1,19);

    if(!
    $string) {
        die(
    "String contained no value.");
    }

    ImageString($image8$xposition$yposition$string$textcolor);

    session_start();



    $_SESSION['imageVeriChars'] = md5($string);

    if(!
    $_SESSION['imageVeriChars']) {
        die(
    "Session not set.");
    }

     


    // send the image
    header("content-type: image/png");
    ImagePNG($image);
    ImageDestroy($image);

    ?>

    Note: This hasn't been tested it since I found it buried deep in my machine and I'm not sure how well if at all it'll work.
     

Share This Page