Home >Backend Development >PHP Tutorial >thinkphp验证码显示不出来的解决方法_PHP

thinkphp验证码显示不出来的解决方法_PHP

WBOY
WBOYOriginal
2016-06-01 11:55:06971browse

ThinkPHP

php的配置文件php.ini,搜索extension=php_gd2.dll,去掉前面的分号即可;

1.在模块类中增加一个 verify 方法来用于显示验证码
复制代码 代码如下:
Public function verify(){
    // 导入Image类库
    import("ORG.Util.Image");
    Image::buildImageVerify();
}

2.表单中使用验证码
复制代码 代码如下:

thinkphp验证码显示不出来的解决方法_PHP

3.验证码刷新
复制代码 代码如下:

4.验证码验证
复制代码 代码如下:
if($_SESSION['verify'] != md5($_POST['verify'])) {
    $this->error('验证码错误!');
}

Statement:
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