Dedecms custom form add verification code tutorial

Source: Internet
Author: User

Some additional forms are required for front-end users to submit in many website construction requirements. This allows you to collect, collect, analyze, and process more data. For example, online orders, online registration, and other common interactive applications.

The custom form function provided by DedeCMS can meet most of these requirements.

By adding a verification code to a custom form, you can prevent malicious submission by some users.

1. Go to the DedeCMS background to generate a custom form.

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

The code is as follows: Copy code

<Input name = "validate" type = "text" id = "vdcode" style = "text-transform: uppercase;" size = "8"/>

<A href = "javascript: vide (-1);" onClick = "changeAuthCode ();"> can't see it clearly? </A>

3. Add the JS code on the current page as follows:

The code is as follows: Copy code
<Script type = "text/javascript" language = "javascript">
// Verification code
Function changeAuthCode (){
Var num = new Date (). getTime ();
Var rand = Math. round (Math. random () * 10000 );
Num = num + rand;
Certificate ('{ver_code'}.css ('Visibility ', 'visable ');
If ($ ("# vdimgck") [0]) {
$ ("# Vdimgck") [0]. src = "../include/vdimgck. php? Tag = "+ num;
    }
Return false;
}
</Script>

4. Modify the order processing page, open the website root directory/plus/diy. Php file, and add the verification code to around 61st lines. As follows:

 

The code is as follows: Copy code
If (! Empty ($ dede_fields ))
       {
$ Validate = empty ($ validate )? '': Strtolower (trim ($ validate); $ svali = strtolower (GetCkVdValue ());
If ($ validate = ''| $ validate! = $ Svali) & preg_match ("/6/", $ safe_gdopen) {ResetVdValue ();
ShowMsg ('verification code is incorrect! ', $ De_add );
Exit;
            }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.