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 6 of 6
  1. #1
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    614
    Thanks
    48
    Thanked 64 Times in 64 Posts

    PHP image being displayed as ‰PNG

    Why won't my image show up? The URL is http://simplyuseless.info/publishare...ha/captcha.php. My only theory is that GoDaddy's free hosting ad is causing the problem. If so, then I guess it will go away when I get a hosting plan. If not, I'd like to find out the problem BEFORE I get a hosting plan. Oh, and here is my code:
    PHP Code:
    <?php session_start();  
    $string '';  
    for (
    $i 0$i 5$i++) { 
        
    $string .= chr(rand(97122));  
    }  
    $_SESSION['rand_code'] = $string;  
    $dir 'fonts/';  
    $image imagecreatetruecolor(17060);  
    $black imagecolorallocate($image000);  
    $color imagecolorallocate($image20010090);
    $white imagecolorallocate($image255255255);  
    imagefilledrectangle($image,0,0,399,99,$white);  
    imagettftext ($image3001040$color$dir."arial.ttf"$_SESSION['random_code']);  
    header("Content-type: image/png");  
    imagepng($image);  
    ?>

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    614
    Thanks
    48
    Thanked 64 Times in 64 Posts
    I hate dynamic imaging, but I need a captcha.

  • #3
    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
    Your code works for me, but I had to use $_SESSION['rand_code'] in both locations.

    Although, before I copied arial.ttf into the root directory, I got an error msg that looks like the attached image. See how your weird ‰PNG is there after the warning? So my theory is, your script is giving you a warning but you have warnings suppressed so all you're seeing is that bit of bogus output. Try cranking up error reporting and see if you get anything.
    Attached Thumbnails Attached Thumbnails PHP image being displayed as ‰PNG-ttfimgerror.png  

  • #4
    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
    With arial.ttf found, I see this.
    Attached Thumbnails Attached Thumbnails PHP image being displayed as ‰PNG-ttfimg.png  

  • #5
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    614
    Thanks
    48
    Thanked 64 Times in 64 Posts
    I think it has to be the GoDaddy ad frame. I've gone through a number of captcha scripts and tutorials and none of them work. I think I'll just start my site off captcha-less and hope it works when I get a hosting plan.

  • #6
    Banned
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    0
    Thanked 1 Time in 1 Post
    hi just try this example works fine for me...

    http://www.white-hat-web-design.co.u...hp-captcha.php


  •  

    Posting Permissions

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