首页 > 解决方案 > Capcha 图像使用 codeigniter 显示为空白

问题描述

我已经安装了升级的 php 7.4.10 版本的 xampp,因为安装的更高版本的验证码没有显示图像显示为空白(代码在白色背景中为空白)。

在此处输入图像描述

请在下面找到代码截图

html 文件 login.phtml 的 Javascript

if(document.frm_login.password.value!="")
            {
            var hash = CryptoJS.HmacSHA256(document.frm_login.password.value, "");
            $('#passwords').text('');
              document.frm_login.password.value=mixUpValues(hash.toString(),
  document.frm_login.keyy.value,document.frm_login.keyy1.value);
        
            }
            
             if(document.frm_login.vercode.value==""||document.frm_login.vercode.value==null)
                 {
                    $('#captcha-code').text('Please enter code!');
                    $('#vercode').focus();
                    return false; 
                     }
                     
            if(document.frm_login.vercode.value!=""||document.frm_login.vercode.value!=null)
                {
                    $('#captcha-code').text('');
                }

login.phtml的html代码

<div class="form-group captcha">
<?php echo $this->form->vercode; ?>         
<p><span><img src="<?php echo $this->baseUrl('cool_capcha/captcha.php'); ?>" 
id="captcha" /></span>
<a  onclick="document.getElementById('captcha').src='<?php echo $this- 
>baseUrl('cool_capcha/captcha.php'); ?>?'+Math.random();
document.getElementById('vercode').focus();"id="change-image" class="menu4 
refresh" style="cursor:pointer">
<img src="./images/refress.png" class ="refresh" id="refresh" /></a></p>
<div class="clearfix"></div><span class="require" id="captcha-code"> 
 </span>
</div> 

表单 Auth.php

 $this->addElement('text', 'vercode', array(
        //'label'      => 'Please enter the 5 letters displayed below:',
        'required'   => true,
        'class'   => 'form-control captchain',
        'placeholder' => 'Captcha',
             'autocomplete' => 'off',
            'decorators'=>Array(
        'ViewHelper',
        'Errors',
       ),
        'validators' => array(
            array('validator' => 'StringLength', 'options' => array(0, 20))
            )
    ));

控制器 AuthController 函数 loginAction()

$captcha = new Zend_Session_Namespace('captcha');
    $captcha->captcha = session_id();
    if($dataform['vercode'] != $_SESSION["vercode"]){
        $msg="Please enter a correct code!";
        $this->view->assign('msg', $msg);
        return false;
    }

标签: codeigniter

解决方案


推荐阅读