CodeIgniter Study Notes (16) Verification code in--CI

Source: Internet
Author: User

First, you need to save the CAPTCHA picture in the directory folder of the portal file, such as the new Captcha directory.

Loading CAPTCHA helper Classes

$this->load->helper (' captcha ');

Call the Create_captcha function to generate a CAPTCHA picture

$this->load->helper (' url ');$vals=Array    (        //captcha text, default is 8-bit random string' word ' = ' Random word ',//Picture Save Path' Img_path ' = './captcha/',//Base directory URL' Img_url ' = Base_url (). './captcha ',//Font files used by fonts in pictures' Font_path ' = './path/to/fonts/texb.ttf ',//Picture Size' Img_width ' + ', ' img_height ' + 30,//time-out deletion (seconds) of the CAPTCHA picture specified, default 2 hours' Expiration ' = 30    );$cap= Create_captcha ($vals);

In addition, you can set the string length, color, font size, optional characters, the return value includes the name of the generated picture, the full img tag, the CAPTCHA string

Since CI is not a session of PHP, the verification process for verification code can be saved directly using the session of PHP.

Session_Start (); $_session $cap [' word '];
Then use the user's input and the value in the session to compare it.

CodeIgniter Study Notes (16) Verification code in--CI

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.