php数字验证码

WBOY
发布: 2016-07-25 09:09:01
原创
765 人浏览过
  1. session_start();
  2. //生成验证码图片
  3. Header("Content-type: image/PNG");
  4. srand((double)microtime()*1000000);
  5. $im = imagecreate(62,20);
  6. $black = ImageColorAllocate($im, 69,120,239);
  7. $white = ImageColorAllocate($im, 0,0,0);
  8. $gray = ImageColorAllocate($im, 200,200,200);
  9. imagefill($im,68,30,$gray);
  10. while(($authnum=rand()%100000)
  11. //将五位整数验证码绘入图片
  12. imagestring($im, 5, 10, 3, $authnum, $white);
  13. for($i=0;$i
  14. {
  15. $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
  16. imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
  17. }
  18. ImagePNG($im);
  19. ImageDestroy($im);
  20. $_SESSION['SESSION_VALIDATE_CODE'] = $authnum.'';
  21. ?>
  22. $txt="memory";
  23. $im = imagecreatetruecolor(400,30);
  24. $white = ImageColorAllocate($im, 255,255,255);
  25. $black = ImageColorAllocate($im, 0,0,0);
  26. // Replace path by your own font path
  27. imagestring($im,1,10,10,$txt,$black);
  28. //imagettftext($im, 20, 0, 10, 20, $black, "font.ttf","Testing...");
  29. header("Content-type:image/jpeg");
  30. imagejpeg($im);
  31. // imagedestroy($im);
复制代码


相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!