In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you the method of phpcms to call CAPTCHA, I hope you will learn a lot after reading this article, let's discuss it together!
How does phpcms call CAPTCHA?
Problem description:
Whether in the template production of phpcms or the secondary development of some functional modules, we often use the CAPTCHA in some forms, so how do we call it?
Solution:
To use CAPTCHA in phpcms website, we need to consider two aspects: how to call CAPTCHA in the front-end template page and how to verify it in the background program:
1. In the template, the code that calls the verification code is as follows:
CAPTCHA {form::checkcode ('code_img',' 4,'14, 100,30)}
Note that the checkcode method in the form class is used from the tag, so make sure that the class has been called in the controller file where the template is located, as follows:
Pc_base::load_sys_class ('form',', 0)
This type of file location / phpcms/libs/classes/form.class.php, you can see the meaning of each parameter by looking at the checkcode method parameter comments in this file.
2. In the back-end controller file php program, the demonstration code is as follows:
Defined ('IN_PHPCMS') or exit (' No permission resources.'); pc_base::load_sys_class ('form','', 0); class index {public function init () {if (isset ($_ POST [' dosubmit'])) {/ / submit data / / launch session $session_storage = 'session_'.pc_base::load_config (' system','session_storage') Pc_base::load_sys_class ($session_storage); / / CAPTCHA if (($_ SESSION ['code']! = strtolower ($_ POST [' code'])) | | empty ($_ SESSION ['code']) {showmessage ("CAPTCHA error");} else {$_ SESSION [' code'] =';}
Here we pay attention to three points:
Second line, don't forget to introduce the form class
Lines 7, 8, 9, introduce session storage configuration and startup corresponding classes (usually mysql) before reading session data
Judge the if condition of session to compare the code value filled in the form with the code value in session
After reading this article, I believe you have a certain understanding of the method of phpcms to call CAPTCHA, want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.