图片验证码有关问题

WBOY
풀어 주다: 2016-06-13 13:50:29
원래의
789명이 탐색했습니다.

图片验证码问题?
如何使用php代码生成随机的图片验证码呀?请发出代码,谢谢大家了!!

------解决方案--------------------
rand()
GD
------解决方案--------------------
session_start();

$password = my_random_password(5);
$_SESSION[ "CheckCode "] = $password;


function my_random_password($length)
{
$result = " ";
$string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789 ";
for ($i = 0 ; $i {
$result .= $string[mt_rand(0 , strlen($string) - 1)];
}
return $result;
}

header ( "content-type: image/gif ");
//图像长宽初始化
$image_x = $_GET[ 'width '];
$image_y = $_GET[ 'height '];
//创建图片
$image = imagecreate($image_x , $image_y);
//定义背景色
$background_color = imagecolorallocate($image , 0xFF , 0xFF , 0xFF);
//定义所需要的颜色
$black_color = imagecolorallocate($image, 100, 50, 255);
$gray_color = imagecolorallocate($image , 0xdd , 0xdd , 0xdd);
//循环生成雪花点
for ($i = 0 ; $i {
imagesetpixel($image , mt_rand(0 , $image_x) , mt_rand(0 , $image_y) , $gray_color);
}
//把随机字符串输入图片
//imagestring($image, 8, 10, 3, $password, $black_color);
imagettftext($image, 12, 0, 5, 17, $black_color, './ariblk.ttf ', $password);
//生成矩形边框
imagerectangle($image , 0 , 0 , $image_x - 1 , $image_y - 1 , $black_color);
//生成图片
imagegif($image);
//释放与$image关联的内存
imagedestroy($image);
?>
------解决方案--------------------
效果请看 http://www.iebsoft.com/imall/system/login.php
------解决方案--------------------
rand()
GD编程~

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!