Home > Backend Development > PHP Tutorial > PHP generates a simple example of a verification code that can be clicked to refresh, PHP generates a verification code example_PHP tutorial

PHP generates a simple example of a verification code that can be clicked to refresh, PHP generates a verification code example_PHP tutorial

WBOY
Release: 2016-07-12 08:52:00
Original
780 people have browsed it

A simple example of PHP generating a verification code that can be clicked to refresh, an example of php generating a verification code

This article describes an example of PHP generating a verification code that can be clicked to refresh. Share it with everyone for your reference, the details are as follows:

html file:

<html>
 <head>
   <title>验证码</title>
 </head>
  <script type="text/javascript">
    function yanzheng(){
      var im=document.getElementsByTagName("img");
      im[0].src="gd.php&#63;temp="+(new Date().getTime().toString(36));
    }
  </script>
 <body>
  <img src="gd.php"/><a href="#" onclick="yanzheng()">换一张</a>
 </body>
</html>

Copy after login

Verification code file gd.php:

<&#63;php
$im=imagecreate(50,20);
$b=imagecolorallocate($im,0,0,0);
$w=imagecolorallocate($im,255,255,255);
$mask="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$text="";
for($i=1;$i<=4;$i++){
  $index=rand(0,61);
  $text.=$mask{$index};
}
imagestring($im,3,rand(10,20),rand(0,10),$text,$w);
header("Content-type:image/jpeg");
imagejpeg($im);
&#63;>

Copy after login

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP graphics and image operation skills", "Summary of PHP file operations", "Summary of PHP operations and operator usage", "PHP network programming" Skills Summary", "PHP Basic Syntax Introductory Tutorial", "php Office Document Operation Skills Summary (including word, excel, access, ppt)", "php date and time usage summary", "php object-oriented programming introductory tutorial", "Summary of php string usage", "Introduction to php mysql database operation tutorial" and "Summary of common php database operation skills"

I hope this article will be helpful to everyone in PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127914.htmlTechArticlePHP generates a simple example of a verification code that can be clicked to refresh, an example of PHP generating a verification code. This article tells an example of PHP generating a clickable verification code. Refresh verification code. Share it with everyone for your reference, the details are as follows:...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template