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 2 of 2

Thread: PHP Captcha

  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Captcha

    Hey guys, I have a captcha script that I downloaded (dont remember from where) and am having some problems with it. Firefox cache's the captcha image and when someone enters the wrong code and hits the back button the same captcha image is shown. It works fine on IE but on Firefox it craps out. Here is the code:

    PHP Code:
    <?php
    session_start
    ();

    s$image imagecreate(12030);
    $white imagecolorallocate($image0xFF0xFF0xFF);
    $gray imagecolorallocate($image0xC00xC00xC0);
    $darkgray imagecolorallocate($image0x500x500x50);

    srand((double)microtime()*1000000);

    for(
    $i 0$i 30$i++) {
        
    $x1 rand(0120);
        
    $y1 rand(030);
        
    $x2 rand(0120);
        
    $y2 rand(030);
        
    imageline($image$x1$y1$x2$y2 $gray);  
    }

    for(
    $i 0$i 5$i++) {
        
    $cnum[$i] = rand(0,9);
    }

    for(
    $i 0$i 5$i++) {
        
    $fnt rand(35);
        
    $x $x rand(1220);
        
    $y rand(712); 
        
    imagestring($image$fnt$x$y$cnum[$i] , $darkgray); 
    }

    $securitycode "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";

    $_SESSION['securitycode'] = $securitycode;

    header("(anti-spam-content-type:) image/png"); // this is content - type
    header("Content-Disposition: filename="securitycode".png");
    imagepng($image);
    imagedestroy($image);

    ?>
    Any help is greatly appreciated.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    header("Content-Disposition: filename="securitycode".png"); 
    That your problem?

    Isn't it meant to be:
    PHP Code:
    header("Content-Disposition: filename=".$securitycode.".png"); 


  •  

    Posting Permissions

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