Home PHP Libraries Verification code library PasswordLibr PHP library for generating verification codes
PasswordLibr PHP library for generating verification codes
<?php
   session_start();
   header("Content-type:image/png");
   $img_width=100;
   $img_height=20;
   srand(microtime()*100000);
   for($i=0;$i<4;$i++)
   {
        $new_number.=dechex(rand(0,15));
   }
   $_SESSION[check_auth]=$new_number;
   $new_number=imageCreate($img_width,$img_height);//创建图象
   ImageColorAllocate($new_number,255,255,255);  //设置背景色为白色
   for($i=0;$i<strlen($_SESSION[check_auth]);$i++)
   {
       $font=mt_rand(3,5);
       $x=mt_rand(1,8) + $img_width*$i/4;
       $y=mt_rand(1,$img_height/4);
       $color=imageColorAllocate($new_number,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));//设置字符颜色
       imageString($new_number,$font,$x,$y,$_SESSION[check_auth][$i],$color);//输出字符
   }
   ImagePng($new_number);
   ImageDestroy($new_number);
?>

The GD library is a very powerful library for image manipulation in PHP.

First add a line of reference in php.ini: extension=php_gd2.dll

Restart apache. Make a test page var_dump(gd_info()); the output data shows that the GD library is referenced successfully.

Form auth.html


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Sharing examples of generating verification codes in PHP, sharing examples of PHP verification codes_PHP tutorial Sharing examples of generating verification codes in PHP, sharing examples of PHP verification codes_PHP tutorial

12 Jul 2016

Sharing examples of generating verification codes in PHP, sharing examples of PHP verification codes. PHP implementation of generating verification code examples sharing, PHP verification code examples sharing image.func.php php require_once('string.func.php'); function verifyImage( $type=1,$length=4,$pixel=0,$line =0,$sess_n

Use GD library to do verification code in php, phpgd library verification code_PHP tutorial Use GD library to do verification code in php, phpgd library verification code_PHP tutorial

12 Jul 2016

In php, GD library is used for verification code, and phpgd library is used for verification code. Use GD library to do verification code in php, phpgd library verification code php require_once 'string.func.php';//Use GD library to do verification code/** *Add verification text* @param int $type * @param int $length */function

Simple and safe PHP verification code with calling method, PHP verification code with calling_PHP tutorial Simple and safe PHP verification code with calling method, PHP verification code with calling_PHP tutorial

12 Jul 2016

Simple and secure PHP verification code with calling method, PHP verification code with calling method. Simple and secure PHP verification code with calling method, PHP verification code with call. 1. Verification code example 2. PHP verification code class, secoder.class.php php /** * Security verification code * * Secure verification

Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo_PHP tutorial Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo_PHP tutorial

12 Jul 2016

Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo. Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo This article describes how Zend Framework generates verification codes and implements verification code verification functions.

The verification code appears when submitted multiple times (3 times)??? The verification code appears when submitted multiple times (3 times)???

06 Jul 2016

1. The graphic verification code does not appear in the first three submissions. 2. The graphic verification code appears after the third time and can be submitted only after verification. What is the basis for counting the number of submissions? IP? Cookie? Session? Or other ideas. If it is a SMS verification code channel, others use dynamic How to control if the IP library is used to attack? http://m.rong3...

A practical php verification code function, php verification code_PHP tutorial A practical php verification code function, php verification code_PHP tutorial

12 Jul 2016

A practical php verification code function, php verification code. A practical php verification code function, php verification code This article shares several php verification code functions for everyone, they are very practical, the specific content is as follows Code segment 1: Simple php verification code function

See all articles