设为首页 加入收藏

TOP

PHP生成图片验证码demo【OOP面向对象版本】(二)
2017-10-10 12:01:15 】 浏览:804
Tags:PHP 生成 图片 验证 demo OOP 面向 对象 版本
72 $img_line .= imageline($this->img, mt_rand(0,$this->img_width), mt_rand(0,$this->img_height), mt_rand(0,$this->img_width), mt_rand(0,$this->img_height), imagecolorallocate($this->img, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255))); 73 } 74 return $img_line; 75 } 76 //session存储验证码 77 private function session_code(){ 78 session_start(); 79 $_SESSION['code'] = $this->code_content; 80 } 81 //判断程序是否支持GD库 82 private function gdcheck(){ 83 if(extension_loaded('gd')){ 84 return true; 85 }else{ 86 return false; 87 exit(); 88 } 89 } 90 }

3、checkcode.php中的代码:

<?php
/**
 * @Description  网站登录/注册验证码生成类
 * @Author  赵一鸣
 * @OnlineDemo http://www.zymseo.com/demo/verificationcode/code.html
 * @Date  2016年10月6日
 */
    header('Content-type:text/html;charset="utf-8"');
    session_start();
    if($_POST['code']!=''){
        if($_SESSION['code']==$_POST['code']){
            echo '<script type="text/java script">
                    alert("验证码填写成功");
                    history.go(-1);
                </script>';
        }else{
            echo '<script type="text/java script">
                    alert("验证码填写失败");
                    history.go(-1);
                </script>';
        }
    }

4、showcode.php中的代码:

 1 <?php
 2 /**
 3  * @Description  网站登录/注册验证码生成类
 4  * @Author  赵一鸣
 5  * @OnlineDemo http://www.zymseo.com/demo/verificationcode/code.html
 6  * @Date  2016年10月6日
 7  */
 8     function __autoload($classname){
 9         include strtolower($classname).'.class.php';
10     }
11     //定义验证码的取值范围
12     $str_content = 'abcdefghijklmnopqrstuvwxyz0123456789';
13     //验证码文字颜色
14     $code_content_color = '#ffffff';
15     //初始化对象
16     $code = new Createcode(100,30,$str_content,$code_content_color);
17     $code->get_img();

原文地址:http://www.zymseo.com/php/334.html

转载请注明出处!

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Nginx配置文件nginx.conf中文详解 下一篇验证坐标在某片坐标区域内 php 代..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目