以下是运行正常的代码,但我想添加自己的背景img而不是蓝色。还想在代码rand中添加字母?请帮忙......
<?php
session_start();
$code=rand(10000,99999);
$_SESSION["code"]=$code ;
$im = imagecreatetruecolor(60, 24);
$bg = imagecolorallocate($im, 22, 86, 165);
$fg = imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5, $code, $fg);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
答案 0 :(得分:0)
使用CAPTCHA的想法是告诉计算机和人类。这个CAPTCHA很容易被OCR程序打破。
话虽如此,您需要执行以下操作:
<?php
session_start();
$code=rand(10000,99999);
$_SESSION["code"]=$code ;
$im = imagecreatefrompng("bg.png");
$fg = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 5, 5, 5, $code, $fg);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>