Phpcms How to add a verification code to the V9 Form Wizard

Source: Internet
Author: User

The form thought relatively simple, so did not add the verification code function. Similar tutorials on the web are mostly inaccurate. So personally tested, found the following method is available. Hope to have the help of friends who need.

1 The first page that invokes the form joins the verification code. Form JS Call Template The default is \phpcms\templates\default\formguide\show_js.html.

Find this line of code in this file, about 23 lines

1 2 3 4 5 6 <tr>       <th width="80">{if $info[‘star‘]} <font color="red">*</font>{/if} {$info[‘name‘]}       </th>       <td>{$info[‘form‘]}  {$info[‘tips‘]}</td>     </tr>{/loop}

Add a line of code below.

1 <tr><td style="text-align:right;">验证码</td><td colspan="2"><span title="点击更换验证码" style=" cursor:pointer;"><input type="text" id="code" name="code" size="8" class="input-text">{form::checkcode(‘code_img‘‘4‘‘14‘8424)}</span>请输入图片中的验证码</td></tr>

2 found this file \phpcms\modules\formguide\index.php

This needs to be modified in two places.

1) Find this line of code on the third line.

0 S defined(‘IN_PHPCMS‘) or exit(‘No permission resources.‘); define(‘CACHE_MODEL_PATH‘,PHPCMS_PATH.‘caches‘.DIRECTORY_SEPARATOR.‘caches_model‘.DIRECTORY_SEPARATOR.‘caches_data‘.DIRECTORY_SEPARATOR);

Then add the following two lines of code to the back

0 S $session_storage = ‘session_‘.pc_base::load_config(‘system‘,‘session_storage‘); pc_base::load_sys_class($session_storage);

2) Find the following line of code

1 2 3 if (isset($_POST[‘dosubmit‘])) { $tablename = ‘form_‘.$r[‘tablename‘]; $this->m_db->change_table($tablename);

Then add the following code below

1 2 3 4 5 6 7 if(!empty($_SESSION[‘code‘])) {    //判断验证码    $code = isset($_POST[‘code‘]) && trim($_POST[‘code‘]) ? trim($_POST[‘code‘]) : showmessage(L(‘input_code‘), HTTP_REFERER);    if ($_SESSION[‘code‘] != strtolower($code)) {     showmessage(L(‘code_error‘), HTTP_REFERER);    }   }

OK, refresh your form page, the random code has come out.

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.