1, add the verification code display in the \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. Modify in \phpcms\modules\formguide\index.php
Specific as follows
<?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 '); Judging the Verification code
Pc_base::load_sys_class ($session _storage); Judging the Verification code
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];
Locate the following code
if (Isset ($_post[' Dosubmit ')) {
$tablename = ' form_ '. $r [' tablename '];
$this->m_db->change_table ($tablename);
Add below:
if (!empty ($_session[' code ')) {
Judging the Verification 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);
}
}
Phpcms v9 Custom Form Add CAPTCHA validation