I'm currently developing a system in CodeIgniter that requires user authentication via login & registration as a base in order to use the rest of the system. I've been having a 404 Not Found issue on my system whenever I try to call a Controller function, this is particularly prevalent on form submissions. I've posted my related code from my Controller, Model, View, Routes and Htaccess below. I'm not entirely sure whats causing the 404 not found error, any help would be greatly appreciated.
Controller:
// handles register page
public function register() {
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = "Register";
$this->form_validation->set_rules('fullname','Full Name','required');
$this->form_validation->set_rules('accountid','Account ID','required');
$this->form_validation->set_rules('password','Password','required');
$this->form_validation->set_rules('type','Account Type','required');
if ($this->form_validation->run() === FALSE) {
$this->load->view('register', $data);
} else {
$fullname = $this->input->post('fullname');
$username = $this->input->post('username');
$password = md5($this->input->post('password'));
$accounttype = $this->input->post('type');
$this->system->registeruser($username, $password, $fullname, $accounttype);
echo "User Registration Complete";
}
}
Model:
public function registeruser($accountid, $password, $fullname, $accounttype) {
$query = "INSERT INTO users VALUES($fullname','$accountid','$password','$accounttype')";
$this->db->query($query);
}
View:
<?php
echo form_open('main/register');
echo validation_errors(); ?>
<div id="name-input">
<?php
$data = array(
'name' => 'fullname',
'value' => $this->input->post('fullname'),
'placeholder' => 'Full Name',
'class' => '',
'style' => 'width:100%; padding:0.5em;' );
echo form_input($data);
echo "</p>"; ?>
</div>
<div id="username-input">
<?php
$data = array(
'name' => 'accountid',
'value' => $this->input->post('accountid'),
'placeholder' => 'User ID',
'class' => 'username',
'style' => 'width:100%; padding:0.5em;' );
echo form_input($data);
echo "</p>"; ?>
</div>
<div id="password-input">
<?php
$data = array(
'name' => 'password',
'value' => $this->input->post('password'),
'placeholder' => 'Password',
'class' => 'passwordd',
'style' => 'width:100%; padding:0.5em;' );
echo form_password($data);
echo "</p>"; ?>
</div>
<div id="account-type">
<?php
$options = array(
'student' => 'Student',
'lecturer' => 'Lecturer' );
$data = array(
'name' => 'type',
'style' => 'width:100%; padding:0.5em;' );
echo form_dropdown($data, $options);
echo "</p>"; ?>
</div>
<div id="submit-button">
<?php
$data = array(
'name' => 'register',
'value' => 'Register Account',
'class' => 'register',
'style' => 'width:100%; padding:0.5em;' );
echo form_submit($data); ?>
</div>
<?php echo form_close(); ?>
Routes:
$route['main/register'] = 'main/register';
$route['default_controller'] = 'main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
All the code above relates to my registration page / it's related functions, I have multiple of these errors on my system currently but they all seem to be the same thing, I figured solving one may solve the rest as well.