1、 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示
<input type="text" id="code" name="code" size="8" class="input-text">{form::checkcode('code_img', '4', '14', 84, 24)}
2、 在 \phpcms\modules\formguide\index.php 中修改
具体如下
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
define('CACHE_MODEL_PATH',PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
$session_storage = 'session_'.pc_base::load_config('system','session_storage'); //判断验证码
pc_base::load_sys_class($session_storage); //判断验证码
class index {
private $db, $m_db, $M;
function __construct() {
$this->db = pc_base::load_model('sitemodel_model');
$this->m_db = pc_base::load_model('sitemodel_field_model');
$this->M = new_html_special_chars(getcache('formguide', 'commons'));
$this->siteid = get_siteid();
$this->M = $this->M[$this->siteid];
找到下面代码
if (isset($_POST['dosubmit'])) {
$tablename = 'form_'.$r['tablename'];
$this->m_db->change_table($tablename);
在下方加入:
if(!empty($_SESSION['code'])) {
//判断验证码
$code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER);
if ($_SESSION['code'] != strtolower($code)) {
showmessage(L('code_error'), HTTP_REFERER);
}
}