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