The custom form of Zhimeng DedeCMS is a very practical tool, such as making online messages and submitting orders. By default, the system can click Submit, which cannot prevent malicious submission. So I can add the verification code function.

The modification method is as follows:

1. First, find the template of the customized form. The template name can be seen in the background customized form.

2. Add a verification code to the template.

<input name="validate" type="text" id="vdcode" style="text-transform:uppercase;" size="8"/>
<img id="vdimgck" align="absmiddle" onClick="this. src=this. src+'?'" style="cursor: pointer;" alt="Can't see clearly? Click to replace" src="../include/vdimgck. php"/>
<a href=”javascript:vide(-1);” onClick=”changeAuthCode();”> Can't see clearly</ a>

3. Add JS code to the template page.

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

4. Open the root directory of the website/plus/diy.php file, add the verification code to the left and right of line 61, and verify on the server.

$validate = empty($validate) ? '' : strtolower(trim($validate));
$svali = strtolower(GetCkVdValue());
if(($validate=='' || $validate != $svali) && preg_match("/6/",$safe_gdopen))
{ResetVdValue();
ShowMsg ('Incorrect verification code! ', - 1,01000);
exit();
}

The above are the four steps of the dream weaving DedeCMS to submit a custom form and add the verification code function. Try it now.

If you think it is not safe, you can also set the field to Required , the required function is combined with the verification code, which greatly improves the security.

Post reply

Can't comment until