CodeIgniter Forums
CI 3 - input class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI 3 - input class (/showthread.php?tid=63449)



CI 3 - input class - paulkd - 10-31-2015

Hi,

Apologies if this is repeated. The documentation says the input class is

Quote:initialized automatically by the system so there is no need to do it manually.

But this code

Code:
$email = $this->input->post('email');

is generating this error

Quote:Fatal error: Call to undefined function post() in /home/ubuntu/workspace/application/controllers/admin/Homepage.php on line 46

What am I doing wrong ? Confused


RE: CI 3 - input class - ivantcholakov - 10-31-2015

Does your Homepage class inherit directly or indirectly the CI_Controller class?
Edit: 2. If no success, see what would happen if you create a constructor for Homepage and inside it you call the parent constructor.


RE: CI 3 - input class - ciadmin - 10-31-2015

I trust you remembered to call the inherited constructor? That is what triggers the automatic loading of goodies.

In your controller:
Code:
function __construct() { parent::__construct();}



RE: CI 3 - input class - Narf - 10-31-2015

(10-31-2015, 01:31 PM)ciadmin Wrote: I trust you remembered to call the inherited constructor? That is what triggers the automatic loading of goodies.

In your controller:

Code:
function __construct() { parent::__construct();}

That's redundant ... the important thing to remember is to call the parent constructor if you use a constructor in your class. Having no __construct() will automatically inherit the parent one.


RE: CI 3 - input class - paulkd - 11-01-2015

Hi All,

Thanks for the responses. I believe the issue was actually with this line

Code:
$password = $this->input-post('password');

I missed the greater than. Blush

Thanks again for the responses.

Paul.


RE: CI 3 - input class - ivantcholakov - 11-01-2015

@Narf
You are correct, I hesitated a little, because I have the habit always to put a constructor in this "placeholder" state as ciadmin has written. This simplifies thinking. And then, rarely this constructor stays as it was initially, the place is prepared for adding more lines.


RE: CI 3 - input class - Narf - 11-01-2015

(11-01-2015, 06:09 AM)ivantcholakov Wrote: @Narf
You are correct, I hesitated a little, because I have the habit always to put a constructor in this "placeholder" state as ciadmin has written. This simplifies thinking. And then, rarely this constructor stays as it was initially, the place is prepared for adding more lines.

Yea, I get the logic behind it, but I'm always against having unnecessary code. Smile