Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    Masai, Johor, Malaysia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Image verification

    I want to make an image verification for user registration verification code. I just can't find a way to make the code.. Can someone help me? Really need the help. Thank you

  • #2
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    There are plenty of posts here on forums, and even a good captcha snippet in snipets subforum. Use search little billy

  • #3
    New Coder
    Join Date
    Aug 2007
    Location
    Wagga, Australia
    Posts
    59
    Thanks
    0
    Thanked 1 Time in 1 Post
    first you need to make sure your hosting server has php compiled with the GD library and has it enabled.
    then what you will want to do is make a random string, here is a quick example (Note: there are lots of ways to do this and this way may be considered unorthodox)

    <?php
    $string = md5(rand(1, 1000));
    $split = str_split($string, 6);
    echo $split[0];
    ?>

    this outputs something similar to:
    f76a89

    and now you have a 6 digit verification code, next what you will want to do is create an image displaying this information.

    <?php
    $string = md5(rand(1, 1000));
    $split = str_split($string, 6);

    header("Content-type: image/png");
    $image = imagecreate(200, 50)
    or die("Error");
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 000, 000, 000);
    imagestring($image, 5, 5, 5, "$split[0]", $text_color);
    imagepng($image);
    imagedestroy($image);
    ?>

    this makes a dynamic image that displays the random string

    then you need to verify that they have entered the correct digits,
    i suggest doing this by creating a session variable thats value is the correct digit combination and in the next script it checks the digits entered against the session variables value. Or you could do real time checking and code up a storm in javascript or ajax.
    Hope this has helped


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •