Welcome Guest, Not a member yet? Register   Sign In
Where to Put Captcha Code?
#4

[eluser]Glowball[/eluser]
Great solution! I made a little helper at application/helpers/captcha_helper.php with this in it, including it in each file by putting it in my autoload.php file.
Code:
if (! function_exists('get_captcha'))
{
    function get_captcha()
    {
        $CI =& get_instance();
        
        $captchaValues = array(
            'img_path'     => './captcha/',
            'img_url'     => 'http://SITENAME.com/captcha/'
            );
        
        $cap = create_captcha($captchaValues);
        
        $captchaData = array(
            'captcha_id'    => '',
            'captcha_time'    => $cap['time'],
            'ip_address'    => $CI->input->ip_address(),
            'word'          => $cap['word']
            );

        $query = $CI->db->insert_string('captcha', $captchaData);
        $CI->db->query($query);
        
        return $cap['image'];
    }
}

Then in my view I just called it like so.

Code:
<?= get_captcha(); ?>

Thanks so much for your quick help!


Messages In This Thread
Where to Put Captcha Code? - by El Forum - 10-01-2008, 11:09 AM
Where to Put Captcha Code? - by El Forum - 10-01-2008, 11:50 AM
Where to Put Captcha Code? - by El Forum - 10-01-2008, 11:56 AM
Where to Put Captcha Code? - by El Forum - 10-01-2008, 12:18 PM
Where to Put Captcha Code? - by El Forum - 11-22-2008, 02:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB