CodeIgniter 404 Bad request error

2019-09-17 20:32发布

问题:

I'm working with codeIgniter. I am making a login form which checks the members details with the database.

However when I click to login I get this error message:

The requested URL /waitronmain/login.php/login/validate_credentials was not found on this server.

However this is my login.php file and as you can see validate_credentials() does exist.

class Login extends CI_Controller{


function index()
{
    $data['main_content'] = 'login_form';
    $this->load->view('includes/template', $data);
}

function validate_credentials()
{
    //load model to query db
    $this->load->model('membership_model');
    $query = $this->membership_model->validate();

    if($query){ //if credentials validated
        $data = array(
            'username' => $this->input->post('username'),
            'is_logged_in' => true

            );

            $this ->session->set_userdata($data);
            redirect('site/members_area');
    }

    else{ //if not validated load login form again.
        $this->index();

    }

}

}

Any idea what's going wrong? I should be going on to the 'members_area' page as I know the details I am entering are correct.

Any help would be much appreciated.

回答1:

what is this??

/waitronmain/login.php/login/validate_credentials

login.php should be not in url i think you should do:

/waitronmain/login/validate_credentials

(assuming you removed index.php from urls and you are inside the waitronmain/ root )