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);
?>





Bookmarks