+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Creation of captcha

  1. #1
    Jaan Guest

    Creation of captcha

    Hey there!

    I was thinking.. there are many users who have asked from me.. how to create a captcha or that image where are those random numbers or letters.. so i thought i'll make one..

    Code:
    <?php
    header
    ('Content-type: image/jpg');
    header('Content-type: image/jpg'); this means that it will be a jpg image (because our background will be jpg)

    Code:
    $im imagecreatefromjpeg ("image.jpg"); 
    $im = imagecreatefromjpeg ("image.jpg"); It will take image.jpg for our image's background
    Code:
    $rand1 rand(1,255);
    $rand2 rand(1,255);
    $rand3 rand(1,255);
    $color imagecolorallocate($im$rand1$rand2$rand3); 
    $rand1 = rand(1,255);-
    $rand2 = rand(1,255);- - Those variables will create a random number from 1 to 255 so we will have a random color for our text
    $rand3 = rand(1,255);-
    $color = imagecolorallocate($im, $rand1, $rand2, $rand3); - This will create a color for our text

    Code:
    $text rand(10009999);
    $font 'text-font.otf';
    $size 30
    $text = rand(1000, 9999); - This will create a random number between 1000 and 9999
    $font = 'text-font.otf'; - This will be our font
    $size = 30; - It will be font's size

    Code:
    imagettftext($im$size07045$color$font$text);
    imagejpeg($im);
    imagedestroy($im); 
    This will put your info together to form a image it's that simple..

    Here's the full code:

    Code:
    <?php
    header
    ('Content-type: image/jpg');
    $im imagecreatefromjpeg ("image.jpg");
    $rand1 rand(1,255);
    $rand2 rand(1,255);
    $rand3 rand(1,255);
    $color imagecolorallocate($im$rand1$rand2$rand3);
    $text rand(10009999);
    $font 'text-font.otf';
    $size 30;
    imagettftext($im$size07045$color$font$text);
    imagejpeg($im);
    imagedestroy($im);
    ?>
    I attached this script's files also It includes text-font.oft, image.jpg and index.php files

    I'll add the part 2 for it also tomorrow i guess
    Attached Files Attached Files
    Last edited by Jaan; 04-29-2008 at 03:26 AM.

  2. CODECALL Circuit advertisement

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Creation of captcha

    Nice tutorial. +rep.

  4. #3
    Jaan Guest

    Re: Creation of captcha

    yay.. thank you

  5. #4
    dreamcoder is offline Newbie
    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0

    Re: Creation of captcha

    Love it, thanks

  6. #5
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creation of captcha

    This might not be safe - ya know, these types of CAPTCHAs have been broken.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  7. #6
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Creation of captcha

    Quote Originally Posted by Xav View Post
    This might not be safe - ya know, these types of CAPTCHAs have been broken.
    Yes, but about 75% of the time they work. Which is a lot better than not having one.

  8. #7
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Creation of captcha

    True, although it's still better to have a safe one.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  9. #8
    Blizz is offline Newbie
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Re: Creation of captcha

    thank you

  10. #9
    Jaan Guest

    Re: Creation of captcha

    You're welcome

  11. #10
    zrhans is offline Newbie
    Join Date
    Feb 2009
    Posts
    3
    Rep Power
    0

    Re: Creation of captcha

    your codes are very helpfull.

+ Reply to Thread
Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. captcha web API
    By debtboy in forum Tutorials
    Replies: 10
    Last Post: 11-23-2011, 01:04 AM
  2. 3D captcha - new captcha technology concept
    By Juraj Rolko in forum Technology Ramble
    Replies: 5
    Last Post: 07-25-2011, 03:44 PM
  3. Captcha for php
    By exodia in forum PHP Development
    Replies: 3
    Last Post: 03-04-2011, 08:09 AM
  4. The Click Captcha
    By Jordan in forum General Programming
    Replies: 5
    Last Post: 11-14-2009, 09:35 AM
  5. Creation of captcha / Part II /Secure forms
    By Jaan in forum PHP Tutorials
    Replies: 47
    Last Post: 07-27-2009, 04:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

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