Home > CMS Tutorial > DEDECMS > body text

Fixed the problem of adding verification code to Dede custom form

(*-*)浩
Release: 2019-12-10 14:29:22
Original
1966 people have browsed it

How to add a dede template to the custom form on the dedecms website with its own verification code.

Fixed the problem of adding verification code to Dede custom form

Sometimes, we need to add a verification code to the custom form on the dede website to prevent malicious filling in and submission of the form.

# We can use the following methods to achieve: (Recommended learning: CMS )

## 首 First, we want to find/plus/diy .php file

Introduce the file in the header:

require_once(DEDEINC.'/membermodel.cls.php');
Copy after login

Then find

elseif($do == 2)
    {  在这个地方加入代码块 
       //验证码验证
        $svali = GetCkVdValue();
         if(preg_match("/1/",$safe_gdopen)){
             if(strtolower($vdcode)!=$svali || $svali=='')
             {
                 ResetVdValue();
                 ShowMsg('验证码错误!', '-1');
                 exit();
             }  
         }
Copy after login

and save the file after modification.

Second step: Insert the code block into the custom form static page using the verification code

<input type="text" class="intxt w200" style="width: 50px; text-transform: uppercase;" id="vdcode" name="vdcode" class="code"/>
<img id="vdimgck" align="absmiddle" onclick="this.src=this.src+&#39;?&#39;" style="cursor: pointer;" alt="看不清?点击更换" src="/include/vdimgck.php"/> 看不清?
Copy after login

You must also reference JQuery# in this static page

##Add the JS code block again

<script type="text/javascript"> 
 $ = jQuery;  
 function changeAuthCode() {  
 var num = new Date().getTime();  
 var rand = Math.round(Math.random() * 10000);  
 num = num + rand;  
 $(&#39;#ver_code&#39;).css(&#39;visibility&#39;,&#39;visible&#39;);  
 if ($("#vdimgck")[0]) {  
 $("#vdimgck")[0].src = "../include/vdimgck.php?tag=" + num;  
 }  
 return false;  
 }  
 </script>
Copy after login
Okay, give it a try now, is it possible to submit the verification code? A simple dedecms custom form dede template comes with the function of verification code.

Generally you will encounter an error on line 172 because there is a missing "}". Just add one on line 172. OK.

The above is the detailed content of Fixed the problem of adding verification code to Dede custom form. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!