简体   繁体   中英

i can't access my class in codigniter

I am having problem accessing my controller.

It show me this:

You tried to access the address https://localhost/web/index.php/Login/validate_credentials , which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page.

Here is my controller (login.php):

    function validate_credentials()
        {       
            $this->load->model('register');
            $query = $this->register->validate();

            if($query) // if the user's credentials validated...
            {
                $data = array(
                    'username' => $this->input->post('username'),
                    'is_logged_in' => true
                );
                $this->session->set_userdata($data);
                redirect('site/members_area');
            }
            else // incorrect username or password
            {
                $this->index();
            }

    }  

Here is my model (register.php):

       <?php
    class Register extends CI_Model{
        function validate(){
    $this->db->where('username', $this->input->post('username'));
    $this->db->where('password', md5($this->input->post('password')));
    $query=$this->db->get('users');
    if($query->num_rows==1){
    return true;
    }
        }

Here is my view (login_view.php):

           <div id="login_form">
        <h1>Login</h1>
        <?php 
        echo form_open('Login/validate_credentials');
        echo form_input('username','Username');
        echo form_password('password','Password');
        echo form_submit('submit','Login');
         echo anchor('login/signup','create Account');

         ?>
         </div>
echo form_open('Login/validate_credentials');

Should be

echo form_open('login/validate_credentials');

login is the file name of the controller, Login is the class name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM