[eluser]sehummel[/eluser]
OK, I admit it. I'm a CI newbie. I'm doing something really basic wrong and I've been at it for a couple of hours and can't find my error.
I have a controller called login. It's in the resources folder in my controllers folder. It loads a view called login_form. But for the life of me it will not load if I go to domain.com/resources/login or domain.com/resources/index. But I can get to it via a route:
Code:
$route['engineering-resources/login'] = "resources/login";
Even when I get to it this way, my form action isn't found. Here is my form:
Code:
<?php
echo form_open('resources/login/validate_credentials'); // resources folder/login controller/validate_credentials method
echo form_input('username', 'Username');
echo form_password('password', 'Password');
echo form_submit('submit', 'Login');
echo anchor('login/signup', 'Create Account');
echo form_close();
?>
The path is my resources folder in my controllers folder, and the controller is the login controller using the validate_credentials method. Here is the pertinent part of my login controller:
Code:
class Login extends Controller {
function index()
{
$data['title'] = 'Engineering Resources | Login';
$data['main_content'] = 'resources/login_form'; // resources folder/login form view
$this->load->view('templates/main.php', $data);
}
function validate_credentials()
{
$this->load->model('login/membership_model'); // login folder, membership_model model
$query = $this->membership_model->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('resources/login/members_area');
}
else // incorrect username or password
{
$this->index();
}
}
The index function works when I use the route, but not when I use the above domain.com paths. I assume that is why it cannot find the validate_credentials method. What am I doing wrong?