Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:32:25+00:00 2026-06-05T01:32:25+00:00

How to create captcha in codeigniter 2.1.0 load helper codeigniter ? when i have

  • 0

How to create captcha in codeigniter 2.1.0 load helper codeigniter ?
when i have model m_captcha :

    function __construct()
{
            parent::__construct();
}

    function setCaptcha()
    {
            $this->load->helper('captcha');
            $vals = array(
                'img_path'          => './asset/captcha',
                'img_url'           => base_url().'/asset/captcha',
                'expiration'        => 3600,// one hour
                'font_path'     => './system/fonts/georgia.ttf',
                'img_width'     => '140',
                'img_height'        => 30,
                'word'          => random_string('numeric', 6),
                );

            $cap = create_captcha($vals);
            if ($cap)
            {
                    $capdb = array(
                        'captcha_id'        => '',
                        'captcha_time'      => $cap['time'],
                        'ip_address'        => $this->CI->input->ip_address(),
                        'word'              => $cap['word']
                    );
                    $query = $this->db->insert_string('captcha', $capdb);
                    $this->db->query($query);
            }else {
                            return "Captcha not work" ;
                     }

                return $cap['image'] ;
}        

and i have controller c_login :

   function __construct()
{
    parent::__construct();
    $this->load->model('m_captcha');
}   

    public function index()
    {
          $this->load->helper('captcha');
          $data = $this->m_captcha->setCaptcha();                            
          $this->load->view('login/v_form',$data);                        
    }

and i have view :

<?php echo form_open('c_login'); ?>
 <?php echo  $cap['image']; ?>
<?php echo form_error('captcha');?>
<?php echo form_close(); ?>

why the captcha cannot show in view ?
position folder and image captcha in sms/asset/captcha .
sms is folder root Codeigniter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:32:26+00:00Added an answer on June 5, 2026 at 1:32 am

    <?php echo $cap['image']; ?> is the problem.

    Lets check the flow once again, you are returning the $cap['image'] from model.

    And after that, you accepted that in $data in controller.

    It must be something $data['capcha'] so that you can access it using $capcha in view.

    Very Simple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the imagettftext() function to create a custom captcha script. I have
I have created a captcha which looks like this: <img src=/cgi-bin/rand.pl /> The problem
I have been given a homework assignment where I need to create a captcha
I have four different server and a load balancer. I want to use captcha
I want to create a CAPTCHA similar to http://www.gigbooks.com/getcaptcha.php this one. But its in
I'm using captcha helper from CodeIgniter to generate Captcha image for registration user. I've
I have created a captcha image making program with PHP <?php function word($n) {
I have to create a image using php ( codeigniter) and need to show
I'm trying to create a Captcha in JavaScript but I ran into issues. I
I used that article on code project to create my own Captcha image, is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.