织梦自定义表单如何增加验证码

来源:互联网 发布:linux安装oracle9i 编辑:程序博客网 时间:2024/06/06 19:09

1.在模板文件中加入如下JS代码:

<script type="text/javascript"> 
 $ = jQuery;  
 function changeAuthCode() {  
 var num = new Date().getTime();  
 var rand = Math.round(Math.random() * 10000);  
 num = num + rand;  
 $('#ver_code').css('visibility','visible');  
 if ($("#vdimgck")[0]) {  
 $("#vdimgck")[0].src = "../include/vdimgck.php?tag=" + num;  
 }  
 return false;  
 }  
 </script>


2.找到对应的php文件,即/plus/diy.php

在头部引入文件:
require_once(DEDEINC.'/membermodel.cls.php');


找到 elseif($do == 2)
    {
********************************
在下面插入代码:
//验证码验证
// $vdcode=$_POST['vdcode'];
      
 
 if(!isset($vdcode))
        {
            $vdcode = '';
        }
        $svali = GetCkVdValue();
 
        if(preg_match("/6/",$safe_gdopen)){
 
            if(strtolower($vdcode)!=$svali || $svali=='')
            {
                ResetVdValue();
                ShowMsg('验证码错误!', '-1');
                exit();
            }
            
        }
**************************************


3.在要添加验证码的位置加入以下代码:

<input type="text" class="entry ent-2 w-156 " style=" width:80px; text-transform: uppercase;" id="vdcode" name="vdcode" class="code"/>
<img id="vdimgck" align="absmiddle" onclick="this.src=this.src+'?'" style="cursor: pointer;" alt="看不清?点击更换" src="/include/vdimgck.php"/> 看不清? <a href="javascript:void(0)" onclick="changeAuthCode();">点击更换</a>




0 0
原创粉丝点击