[eluser]RaGe10940[/eluser]
Hello,
I have a controller like so :
Code:
public function index() {
$data['content'] = 'homepage/login';
$this -> load -> view('templates/no_jsTemplate', $data);
}
Where index() is the login page ( first page any one will ever see)
Now that index page has a function that the form will send to which is :
Code:
public function login_user() {
$this -> load -> library('form_validation');
if ($this -> form_validation -> run('c_homepage/login_user') == FALSE) {
$this -> index();
} else {
$this -> load -> model('m_homepage');
$this -> m_homepapge -> login_user();
}
}
is it possible to condense this? I feel like having two controller functions per page is excessive no?
I tried this :
Code:
public function index() {
if (!$this -> input -> post('login_user')) {
// check if submit is clicked, if not then just load the data array and show the view
$data['content'] = 'homepage/login';
$this -> load -> view('templates/no_jsTemplate', $data);
} else { // if it is clicked load the library and then do the validation and then load the model if validation passes and then do the login_user business calculation
$this -> load -> library('form_validation');
if ($this -> form_validation -> run('c_homepage/login_user') == FALSE) {
$this -> index();
} else {
$this -> load -> model('m_homepage');
$this -> m_homepapge -> login_user();
}
}
}
but when doing this, this keeps me in a infinite loop of sorts.