• Verify human form submission by image verification

    Please follow below steps to verify human form submission by image verification.

    Create PHP form first.

    form.php

    Please enter the string shown in the image.

    validate.php

    “; //echo(“$user”); if($user==$key) { echo (“Verification success”); } else{ echo “You have entered wrong verification code!!
    Please go back and enter proper value.”;} ?>

    Cap_Img.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    
    <!--?php 
     
    session_start();
     
    $md5_hash = md5(rand(0,9999));
     
    $security_code = substr($md5_hash, 25, 5);
     
    $enc=md5($security_code);
     
    $_SESSION['count'] = $enc;
     
    $secure = $_SESSION['count'];
     
    // echo "--------------------------$secure<br ?-->";
     
    $width = 100;
     
    $height = 40;
     
    $image = ImageCreate($width, $height);
     
    $white = ImageColorAllocate($image, 255, 255, 255);
     
    $black = ImageColorAllocate($image, 0, 100, 0);
     
    $grey = ImageColorAllocate($image, 204, 204, 204);
     
    ImageFill($image, 0, 0, $grey);
     
    //Add randomly generated string in white to the image
     
    ImageString($image, 10, 30, 10, $security_code, $black);
     
    ImageRectangle($image,0,16,$width-1,$height-1,$grey);
     
    imageline($image, 0, $height/2, $width, $height/2, $grey);
     
    imageline($image, $width/2, 0, $width/2, $height, $grey);
     
    header("Content-Type: image/jpeg");
     
    ImageJpeg($image);
     
    ImageDestroy($image);
     
    ImageDestroy($image);
     
    ?&gt;

    Run form.php in your browser for result.

    Tags:

Comments on this post

Leave a Reply

  • Security Code :


    8 − = three