Home > CMS Tutorial > DEDECMS > How to add verification code in custom form in DedeCMS

How to add verification code in custom form in DedeCMS

藏色散人
Release: 2020-01-04 09:53:52
Original
2332 people have browsed it

How to add verification code in custom form in DedeCMS

How to add verification code in the custom form of DedeCMS?

Dreamweaver DedeCMS adds verification code in the custom form

Recommended learning: 梦weavercms

1. First enter the DedeCMS backend Generate custom forms.

2. Add verification code to the custom form template, as follows:

<input name="validate" type="text" id="vdcode" style="text-transform:uppercase;" size="8"/> 
<img id="vdimgck" align="absmiddle" onClick="this.src=this.src+&#39;?&#39;" 
style="cursor: pointer;" alt="看不清?点击更换" src="../include/vdimgck.php"/>  
<a href="javascript:vide(-1);" onClick="changeAuthCode();">看不清? </a>
Copy after login

3. Add JS code to the current page, as follows:

<script type="text/javascript" language="javascript">
//验证码 
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

4. Modify the order Process the page, open the /plus/diy.php file in the website root directory, and add the verification code to around line 61. As follows:

if(!empty($dede_fields))
{
 $validate = empty($validate) ? &#39;&#39; : strtolower(trim($validate)); 
 $svali = strtolower(GetCkVdValue()); 
if(($validate==&#39;&#39; || $validate != $svali) && preg_match("/6/",$safe_gdopen)){
 ResetVdValue(); 
 ShowMsg(&#39;验证码不正确!&#39;,$dede_add,0,1000); 
 exit; 
}
Copy after login

Note: My custom form is proposed separately to make a template page and is called using columns.

The above is the detailed content of How to add verification code in custom form in DedeCMS. 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