Welcome Guest, Not a member yet? Register   Sign In
Page not found
#1

[eluser]sehummel[/eluser]
I'm new to CI and I'm having a very basic problem I can't figure out. I have a form and I have it call a method. But I get a page not found error.

Here is my code:

home.php:
<?php

// File Details:
class Home extends Controller {

function index() {
$data['title'] = 'Home Page';
$data['main_content'] = 'home_view';
$this->load->view('templates/main.php', $data);
}

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

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

$this->session->set_userdata($data);
redirect('engineering_resources/members_area');
} else {
$this->index();
}

}


}
?>


And home_view.php

<div id="login-form">
<h3>Login Here</h3>
&lt;?php
echo form_open('validate_credentials');
echo form_input('username', 'User name');
echo form_password('password', 'Password');
echo form_submit('submit', 'Login');
echo anchor('signup', 'Create Account');
?&gt;
</div>

Can anyone see what I'm doing wrong here?
#2

[eluser]Bart v B[/eluser]
i think it's your form that causing the problem.

Code:
&lt;?php
echo form_open('home/validate_credentials');

You only go to the second segment and forgot the first segment witch means you dont use your controller. Wink
#3

[eluser]sehummel[/eluser]
I tried that and it doesn't work. Home is my default controller, so that's why I didn't have that in the form path. Any other thoughts?
#4

[eluser]sehummel[/eluser]
I'm not an Apache server. I'm on IIS. (We're going to move the site later.) Could that be the problem?
#5

[eluser]Bart v B[/eluser]
Yup. That can be causing the problem. Wink
IIS does not have mod_rewrite by default.

You can try to put an index.php between the controller and segment.
Code:
&lt;?php
echo form_open('index.php/home/validate_credentials');

Better is just download WAMP and start building with an apache server is much easier, then with IIS.




Theme © iAndrew 2016 - Forum software by © MyBB