I am creating a form error logger, but since my register.php controller is getting full I thought of moving this to a helper but the problem is I cannot use $this.
Yes I have checked and there are some anwsers that fix this problem by using:
function test()
{
$CI =& get_instance();
$CI->load->database();
echo $CI->db->hostname; // give the config name here (hostname).
}
(Quoted from Acess database config variables from a helper)
However my problem with this it that I can only use one model per function and seeing as my code I am trying to move is this:
function submitCheck() {
$this->load->model("User");
if(empty($post)) { //If anything is empty the view will be loaded
$this->load->view('includes/header.php');
$this->load->view('error_message.php');
$this->load->view('includes/footer.php');
if(empty($post['firstname'])) //This is for the error log
{
$this->load->helper('array', 'error'); //Loading the helper
echo $msg = errorLog('firstname');
$this->load->view('error_message.php');
}
if(empty($post['mail'])) //This is for the error log
{
$this->load->helper('error'); //Loading the helper
echo $msg = errorLog('mail');
}
}
else
{
echo "Everything is filled in";
}
}
So if following the code example i'd have to make around 4/5 functions for every $this. Should I create a loader that in term loads other loaders or can I use the user_loader to load other views/models as well.
I am a starter with codeIgniter so I might've just thinked too difficult and there is an easy fix but I can't find it. Any help is appriciated
Thanks in advance!