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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Captcha

  1. #1
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Question Captcha

    How to create a captcha, have tried lines of captcha code but images are always blank.
    So how do I do this?
    Thanks for you support!

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,091
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Are you trying to incorporate someone else's captcha code into one of your existing web pages, or what? Post your code. It's impossible to offer you any real help without that.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I am using a tutorial and it's all blank.
    Thanks for you support!

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,091
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Did you download code from the tutorial? How about posting a link to the tutorial you're using?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #5
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Quote Originally Posted by westmatrix99 View Post
    I am using a tutorial and it's all blank.
    Hello there! It's always good to post as much information as is possible for each situation. If there is code that has a problem, post it. If you're using a tutorial, post it. If there's a page we can look at that isn't showing up correctly, post it and the code it uses...etc. etc. Be as descriptive as possible! Good luck!

  • #6
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    The tutorial is on this site:

    http://codewalkers.com/tutorials/95/1.html
    Thanks for you support!

  • #7
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    PHP Code:
    <?php
    //Start the session so we can store what the code actually is.
    session_start();

    //Now lets use md5 to generate a totally random string
    $md5 md5(microtime() * mktime());

    /*
    We dont need a 32 character long string so we trim it down to 5
    */
    $string substr($md5,0,5);


    /*
    Now for the GD stuff, for ease of use lets create
     the image from a background image.
    */

    $captcha imagecreatefrompng("./captcha.png");

    /*
    Lets set the colours, the colour $line is used to generate lines.
     Using a blue misty colours. The colour codes are in RGB
    */

    $black imagecolorallocate($captcha000);
    $line imagecolorallocate($captcha,233,239,239);

    /*
    Now to make it a little bit harder for any bots to break, 
    assuming they can break it so far. Lets add some lines
    in (static lines) to attempt to make the bots life a little harder
    */
    imageline($captcha,0,0,39,29,$line);
    imageline($captcha,40,0,64,29,$line);
    /*
    Now for the all important writing of the randomly generated string to the image.
    */
    imagestring($captcha52010$string$black);


    /*
    Encrypt and store the key inside of a session
    */

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

    /*
    Output the image
    */
    header("Content-type: image/png");
    imagepng($captcha);
    ?>
    thats the code he is using, to save you all from multipages of code i compiled into easy view

  • #8
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Cool thanks, will try to figure it out.

    Cheers
    Thanks for you support!

  • #9
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    When I run it I get this error:

    Fatal error: Call to undefined function imagecreatefrompng() in c:\Inetpub\wwwroot\usermail\untitled.php on line 19
    This on line 19:

    $captcha = imagecreatefrompng("./captcha.png");
    Any idea?
    Thanks for you support!

  • #10
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,091
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Have you read what the manual says about imagecreatefrompng? There are a couple of warnings about things which could cause this command to fail.

    The easiest way to find out the settings on your server is to create a file with the following:

    Code:
    <?php
    phpinfo();
    ?>
    Upload that file to your server, run it, and check what the settings are for allow_url_fopen. That should be set to On.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #11
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Yes it's on
    Thanks for you support!

  • #12
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I ran this to test it
    Code:
    <?php
    if (!function_exists('imagecreatefromjpeg')) { 
         echo 'imagecreatefromjpeg() exists.'; 
    }  
    ?>
    and it returns this:

    imagecreatefromjpeg() exists.
    Thanks for you support!

  • #13
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Your logic is looking to see if the function "imagecreatefromjpeg" does NOT exist (evident from the ! which means "NOT"), but your text is printing "exists." Do it like this:

    PHP Code:
    <?php
    if (function_exists('imagecreatefromjpeg')) { 
         echo 
    'imagecreatefromjpeg() exists.'
    } else {
         echo 
    'imagecreatefromjpeg() does not exist.';
    }
    ?>

  • #14
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I tried for all and got a good response but still get an error:


    <?php
    if (!function_exists('imagecreatefromjpeg')) {
    echo 'imagecreatefromjpeg() exists.<br>';
    }
    if (!function_exists('imagecreatefromgif')) {
    echo 'imagecreatefromgif() exists.<br>';
    }
    if (!function_exists('imagecreatefrompng')) {
    echo 'imagecreatefrompng() exists.<br>';
    }
    ?>
    Thanks for you support!

  • #15
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You don't have the GD library installed. You are confused as to what you are checking on those "if" statements-- you are saying if (NOT function_exists()) echo 'function exists!', so the fact they are all returning 'function exists' means they don't exist.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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