SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    urgent issue pls help

    my captcha code is below it is working well in the localhost but when i uploaded it to the server its not showing any thing only blank page is displaying why tell any one plsssssss.............

    <?php
    session_start();


    $width = 240;
    $height = 90;
    $im = imagecreate($width, $height);
    $bg = imagecolorallocate($im, 0, 0, 0);

    // generate random string
    $len = 5;
    $chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
    $string = '';
    for ($i = 0; $i < $len; $i++) {
    $pos = rand(0, strlen($chars)-1);
    $string .= $chars{$pos};
    }
    $_SESSION['captcha_code'] = md5($string);

    // grid
    $grid_color = imagecolorallocate($im, 0, 175, 0);
    $number_to_loop = ceil($width / 20);
    for($i = 0; $i < $number_to_loop; $i++) {
    $x = ($i + 1) * 20;
    imageline($im, $x, 0, $x, $height, $grid_color);
    }
    $number_to_loop = ceil($height / 10);
    for($i = 0; $i < $number_to_loop; $i++) {
    $y = ($i + 1) * 10;
    imageline($im, 0, $y, $width, $y, $grid_color);
    }
    $noice_color = imagecolorallocate($im, 0, 0, 230);
    for( $i=0; $i<($width*$height)/150; $i++ ) {
    imageline($im, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    }

    // random lines
    $line_color = imagecolorallocate($im, 130, 0, 0);
    for($i = 0; $i < 30; $i++) {
    $rand_x_1 = rand(0, $width - 1);
    $rand_x_2 = rand(0, $width - 1);
    $rand_y_1 = rand(0, $height - 1);
    $rand_y_2 = rand(0, $height - 1);
    imageline($im, $rand_x_1, $rand_y_1, $rand_x_2, $rand_y_2, $line_color);
    }

    // write the text
    $text_color = imagecolorallocate($im, 255, 0, 0);
    $rand_x = rand(0, $width - 20);
    $rand_y = rand(0, $height - 15);

    //$font_size = $height * 0.35;
    //$font = 'monofont.ttf';
    //$textbox = imagettfbbox($font_size, 50, $font, $string) or die('Error in imagettfbbox function');
    //$x = ($width - $textbox[4])/2;
    //$y = ($height - $textbox[5])/2;
    //$g=rand(20,0);
    //$k=rand(0,120);

    //imagettftext($im, $font_size, rand($g,$k), $x,$y, $text_color, $font , $string) or die('Error in imagettftext function');

    imagestring($im, 5, $rand_x, $rand_y, $string, $text_color);


    header ("Content-type: image/png");
    imagepng($im);

    ?>

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Have you checked to see if the GD library is installed on the server?

    PHP Code:
    <?php
    var_dump
    (
        
    extension_loaded('gd')
    );
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2009
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello friend its giving bool(true) so it is enabled i dont know why then pls can u tell


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
  •