1 show.php
2
3 <?php
4 session_start();
5 if($_POST[check]){
6
7 if($_POST[check]==$_SESSION[check_pic]){
8 echo "验证码正确".$_SESSION[check_pic];
9 }
10 else {
11 echo "验证码错误".$_SESSION[check_pic];
12 }
13 }
14
15
16 ?>
17 <form action="" method="post">
18 <img src="checkTest.php" /><br />
19 <input name="check" type="text" /><br />
20 <input name="" type="submit" value="提交"/>
21 </form>check.php<?php
session_start();
for($i=0;$i<4;$i++)
{
$rand.= dechex(rand(1, 15));
}
$_SESSION[check_pic]=$rand;
$im=imagecreatetruecolor(100, 30);
//set color
$bg=imagecolorallocate($im, 0, 0,0);//background color
$te=imagecolorallocate($im, 255, 255, 255);
for($i=0;$i<3;$i++){
$te2=imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255));
//set line
imageline($im, rand(0,100), 0, 100, 30, $te2);
}
for($i=0;$i<200;$i++){
imagesetpixel($im, rand()%100, rand()%30, $te2);
}
$str=iconv("gbk", "UTF-8", "显示UTF-8");
imagettftext($im, 14,9,20,20,$te,\'CHILLER.TTF\', $str);
//
//imagestring($im, rand(1, 6),rand(3, 70), rand(0, 15), $rand, $te);
//show
header("Content-type:image/jpeg");
imagejpeg($im);
?>show.php
相关文章:
- PHP简单的手机验证码验证过程 2021-11-18
- php验证码代码 - gavin_echo 2021-12-03
- 制作简单安全的php验证码类代码实例 2021-12-03
- 简单实用的PHP验证码类 2021-11-08
- php写简单的随机验证码 2021-09-04
- 简单程序代码验证 2021-11-03
- php生成动态验证码 加减算法验证码 简单验证码 2022-12-23
- Java最简单的四位验证码验证 - private_mingmie 2021-11-04