![]() |
Personal library and Undefined property $input - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Personal library and Undefined property $input (/showthread.php?tid=54202) Pages:
1
2
|
Personal library and Undefined property $input - El Forum - 08-28-2012 [eluser]luca89pe[/eluser] Hi, i'm new in codeigniter (i started last week using this really nice framework for a simplce project). First of all, thank you for this usefull framework! Then my problem is: i want to make a simple authentication script (i don't need many users, only 1 user that can be add news and somethings, so i thought code a simple library that i can use in every page i need my authentication system. I created my Login.php with this code: Code: <?php Code: function index() { Code: A PHP Error was encountered Thank you and sorry for my bad english! Personal library and Undefined property $input - El Forum - 08-28-2012 [eluser]DarkManX[/eluser] you login library (class) doesnt extends from anything and it has the properties you coded. you need to refer to the CI object to use other library like input. Code: $CI =& get_instance(); Personal library and Undefined property $input - El Forum - 08-28-2012 [eluser]luca89pe[/eluser] Oh, i'm so thanks to you, now it works!! ![]() Luca Personal library and Undefined property $input - El Forum - 08-28-2012 [eluser]DarkManX[/eluser] you should save the instance of the ci-object to your library property in the controctor, so you dont have to copy&paste; for each method. something like that: Code: function __construct(){ Personal library and Undefined property $input - El Forum - 08-29-2012 [eluser]luca89pe[/eluser] Thank you to DarkManX too! I wrote this: Code: function __construct() { Code: if (!isset($_SERVER['PHP_AUTH_USER'])) { Code: if (!isset($_SERVER['PHP_AUTH_USER'])) { Code: if (!isset($this->CI->input->server['PHP_AUTH_USER'])) { Personal library and Undefined property $input - El Forum - 08-29-2012 [eluser]CroNiX[/eluser] because the input method returns boolean FALSE if it doesn't exist....so it will always be set making your isset() check useless. Try Code: if ($this->CI->input->server('PHP_AUTH_USER') !== FALSE) also input->server() has (), not [] as it's not an array. It's a method returning a value. Personal library and Undefined property $input - El Forum - 12-21-2012 [eluser]luca89pe[/eluser] i had to leave this project some times ago, but now i can work on this again! So, this is my code now: Code: <?php Code: A PHP Error was encountered Personal library and Undefined property $input - El Forum - 12-21-2012 [eluser]InsiteFX[/eluser] Code: class your_library { Personal library and Undefined property $input - El Forum - 12-21-2012 [eluser]luca89pe[/eluser] Ty for your reply, didn't noticed i wrote that out the class declaration!!!!!!!! But still not work ![]() Code: A PHP Error was encountered Why it doesn't show dialog ![]() Personal library and Undefined property $input - El Forum - 12-21-2012 [eluser]CroNiX[/eluser] It's because in places you are still checking for $this->input->post when it should be $this->CI->input->post (in your elseif). The error messages are pretty clear. It's the exact same problem as your original. |