![]() |
Captcha error word_length - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Captcha error word_length (/showthread.php?tid=65564) |
Captcha error word_length - msheath - 06-26-2016 I am testing Captcha and my code is like this: Code: $this->load->helper('captcha'); This works OK but if the 'word' line is commented out I get a php error Undefined variable: word_length although the User Guide says 'If a word is not supplied, the function will generate a random ASCII string.' Is this a bug or have I made a mistake in the coding? RE: Captcha error word_length - BabalooAye - 07-08-2016 Don't comment out the 'word' string inside the array. You can put the string with no value, or NULL value. Try something like this: $vals = [ 'word' => NULL, 'img_path' => CAPTCHA_IMG_PATH, 'img_url' => site_url('publico/imagens/captcha'), 'img_width' => '150', 'img_height' => '30', 'font_path' => FONTS_PATH . 'ArialMTRegular.ttf', 'expiration' => $this->config->item('captcha_expiration', 'captcha'), 'word_length' => 6, 'font_size' => 14, 'img_id' => 'captcha-image', 'img_alt' => 'failed-to-captcha-image', 'pool' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'colors' => [ 'background' => array(255, 255, 255), 'border' => array(255, 255, 255), 'text' => array(255, 120, 120), 'grid' => array(255, 182, 182) ] ]; $cap = create_captcha($vals); echo $cap['image']; |