codeigniter - 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;
}
解决方案
推荐阅读
- java - 调用 onResume 时出现 NFC DeadObjectException
- elasticsearch - 如何获取与部分文本匹配的元素
- node.js - 如何扫描表中的所有项目并删除它们?
- javascript - 未使用 Webpack 4 和 MiniCssExtractPlugin 将 CSS 添加到 /dist 文件夹
- .net - 处理过滤数据时如何在领域中进行过滤
- javascript - 使用节点 v11.10.0 在 Meteor 项目中出现语法错误
- nuget - 创建一个 nuget 包以将引用添加到类型库中
- php - 基于认证准备的PHP Typehint问题
- selenium - 如何使用 Selenium 检查 Firefox 扩展的元素
- java - 为什么我得到“找不到的'entityManagerFactory'”。