スクリプトを実装するのが苦労して、私はCaptchaコードを見つけました。 PHPに慣れていないので、どんな助けも素晴らしいでしょう。PHP Captcha Imagettftextが動作しない
問題:キャプチャイメージはライブサーバーには表示されませんが、ローカルサーバーでは表示されます。
検証ファイル:
<?php
header('Content-type: image/jpeg');
$width = 90;
$height = 30;
$dir = getcwd().'/fonts/';
$black = imagecolorallocate($my_image, 0, 0, 0);
$angle = rand(0,3);
imagefilledrectangle($image,0,0,399,99,$white);
$my_image = imagecreatetruecolor($width, $height);
imagefill($my_image, 0, 0, 0xFFFFFF);
// adds noise
for ($c = 0; $c < 50; $c++){
$x = rand(0,$width-1);
$y = rand(0,$height-1);
imagesetpixel($my_image, $x, $y, 0x000000);
}
$x = rand(10,12);
$y = rand(10,15);
$rand_string = rand(1000,9999);
//imagestring($my_image, $font, $x, $y, $rand_string, 0x000000);
imagettftext ($my_image, 22, $angle,10, 27, $black, $dir."arial.ttf", $rand_string);
setcookie('tntcon',(md5($rand_string).'a4xn'));
imagejpeg($my_image);
imagedestroy($my_image);
?>
お問い合わせフォーム:
<img src="verification.php?<?php echo '<span>'.rand(0,9999).'</span>';?>" alt="Anti spam verification" class="verify" />
- フォントは "フォント"
yをありがとう題しルートフォルダにあります。皆さんのご意見をお待ちしています。
ライン 'ヘッダ( 'コンテンツタイプ:image/jpegの')コメントアウト問題(i)を見つけるために、'(ii)のライン 'ini_set( "はdisplay_errors"、 "オン")を追加します。 error_reporting(E_ALL); '(iii)質問を編集し、エラーや警告を追加します。 –
PS:imgの 'src'属性内のspanタグは何ですか?それは壊れたhtmlです。 –