Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hello guys i have a problem with my code... I can't call function form_open('administrator/login') from my view... this is my view

<?php echo form_open('administrator/login'); ?>                                         

                        <p class="imglogin">Form Login</p>
                <div class="control-group">
                     <label class="control-label" for="inputEmail">Username</label>
                    <div class="controls">
                        <input type="text" name="username" />
                    </div>
                </div>
                <div class="control-group">
                     <label class="control-label" for="inputPassword">Password</label>
                    <div class="controls">
                        <input type="password" name="password" id="inputPassword" />
                    </div>
                </div>
                <div class="control-group">
                    <div class="controls">
                         <button type="submit" class="btn">Sign in</button>
                    </div>
                </div>
            <?php echo form_close(); ?>
share|improve this question
2  
What do you mean you can't call it ? Do you get any error ? Have you loaded the form helper first ? – Lepidosteus Jun 12 at 0:03

closed as too localized by relentless, Lepidosteus, andrewsi, jball, TheHippo Jun 12 at 16:57

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

2 Answers

i am guessing you have not loaded the form library. autoload the form library like this go to this file

applications/config/autoload

look for the $autoload[helper] and replace that line with below one.

$autoload['helper'] = array('url', 'form');

OR use this in ur controller

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

Hopefully this will solve your problem.


Edit: I saw your Reply, and found your Problem as you have used the form in autoload function as well as you have loaded the form in controller function it self. You only need to load the form only One Time, or it might will cause problem.

remove $this->load->helper('form') from your controller function as you have loaded the form through autoload already :)

share|improve this answer

this is my $autoload[helper] $autoload['helper'] = array('url','text','form', 'file');

this is my controller administrator.php

    public function login(){
        $this->load->helper('form');
    $username =$this->input->post('username',TRUE);
    $password =$this->input->post('password',TRUE);
    $this->db->where('USERNAME', $username);
    $this->db->where('PASSWORD', md5($password));
    $query =$this->db->get('admin');

}

but it still can't call the function login from view..

404 Page Not Found The page you requested was not found.

sorry if my english is bad :D

share|improve this answer
For one you have loaded the form helper two times. please remove one of them. i have updated my answer too. Also Page not found function refers too that you might have not pointed to the right controller or have not included the right path to the view. Please check your controller and view paths. – Syed Haider Hassan Jun 13 at 20:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.