• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 3 - input class

#1
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
Reply

#2
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.
Reply

#3
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();}
Reply

#4
(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.
Reply

#5
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.
Reply

#6
@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.
Reply

#7
(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
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.