2014-12-27 79 views
0

iam在我的註冊表單上使用captcha .....代碼本身很好......我在多臺服務器上使用過它,今天我重新測試了一下以確保.....但我有一個服務器,evrything運行良好,除了驗證碼不想顯示.... PHP:5.5.11 操作系統:CentOS(5.11) 我認爲這是服務器相關的問題任何想法?我認爲這個問題是與GD庫,但他們也顯示爲安裝並運行良好驗證碼不能在我的CentOS服務器上工作

<?php 
// Set the header 
header("Content-type: image/jpeg"); 

// Start the session 
session_start(); 

// Generate the 5 digits string 
$text = rand(10000,99999); 

// Store the generated code into the _SESSION captcha 
$_SESSION['captcha'] = $text; 

// Define the Image Height & Width 
$width = 75; 
$height = 37; 

// Create the Image 
$image = imagecreate($width, $height); 

// Set the background color 
//$black = imagecolorallocate($image, 88, 180, 22); 
//$black = imagecolorallocate($image, 233, 98, 67); 
    $black = imagecolorallocate($image, 68, 138, 191); 
// Set the text color 
$white = imagecolorallocate($image, 255, 255, 255); 

// Set the font size 
$font_size = rand(); 

// Generate noise 
// for($noise = 0; $noise <= 20; $noise++) { 
    // $x = mt_rand(10, $width-10); 
    // $y = mt_rand(10, $height-10); 
    // imageline($image, $x, $y, $x, $y, $white); 
// } 

// Draw the string with the given coordinates 
imagestring($image, $font_size, 15, 10, $text, $white); 

imageline($image, 0, mt_rand(5, $height-5), $width, mt_rand(5, $height-5), $white); 
imageline($image, mt_rand(10, $width-10), 0, 0, mt_rand(10, $width-10), $white); 

// Output the $image, don't save the file name, set quality 
imagejpeg($image, null, 100); 
?> 
+0

「不下去了」非常含糊。你得到什麼錯誤? – 2014-12-27 16:28:09

+0

那麼問題是我沒有得到任何錯誤 – mikeer 2014-12-28 10:56:05

+0

請參閱http://stackoverflow.com/q/845021/3794472 – 2014-12-28 11:56:21

回答

0

原來放是GD庫,我不得不重新編譯我的PHP

相關問題