Begginer ask |
[eluser]Kentus[/eluser]
Ok, i'm new in this domain, and i want in this topic to expose my problems that i'll receive for this framework. I buy a domain: http://earth-war.eu/ and i tried to make the samples from video tutorials where i'll learn to make my own blog. For the first video i've received some errors: first said that: Fatal error: Class 'Controller' not found in /home2/earthwar/public_html/Blog/application/controllers/blog.php on line 3 for the next code: <?php class Blog extends Controller{ function index() { echo'Hello World' } } ?> I replaced Controller() with CI_Controller and worked, but when i tried to create the constructor i received this: Fatal error: Call to undefined method CI_Controller::CI_Controller() in /home2/earthwar/public_html/Blog/application/controllers/blog.php on line 7 I replaced with Controller but same error undefined method CI_Controller::Controler(). The code: <?php class Blog extends CI_Controller{ function Blog() { parent::CI_Controller(); } function index() { $data['title']="My Blog Title"; $data['heading']="My Blog Heading"; $data['todo']=array('Clean house','eat lunch','call mom'); $this->load->view('blog_view',$data); } } ?> Please help i'm a little stuck on this error and i don't know what to do. Thanks a lot for future help. One more thing.. if you see errors in my grammar or my exprimation pls correct me if you have time). Thanks again
[eluser]danmontgomery[/eluser]
You need to use __construct(), not the class name. Code: class Blog extends CI_Controller { http://ellislab.com/codeigniter/user-gui...llers.html Quote:If you intend to use a constructor in any of your Controllers, you MUST place the following line of code in it:
[eluser]Kentus[/eluser]
thanks, i was translated on the video and didn't search on that page. sory for my lazy to search in site.
[eluser]Kentus[/eluser]
Ok..now i began the work and i've got another problem. I've created a login page and after the member_area page is loading, in my session my username variable is empty. I've tried two sollutions: First: This is where my function is define. function members_area() { $data['main_content']='members_area'; $data['username']=$this->session->userdata('username'); $this->load->view('includes/template',$data); //$this->load->view('members_area'); } This is my view_page: <div id="mainContent"> <div id="userPanel"> <h3>Account Details</h3> Wellcome: <?php $username?> </div> <!-- se inchide userPanel--> </div><!-- se inchide mainContent--> and second ideea is: function members_area() { $data['main_content']='members_area'; $this->load->view('includes/template',$data); //$this->load->view('members_area'); } This is my view_page: <?php $username=$this->session->userdata('username'); <div id="mainContent"> <div id="userPanel"> <h3>Account Details</h3> Wellcome: <?php $username?> </div> <!-- se inchide userPanel--> </div><!-- se inchide mainContent--> Not Works. above this member_area function i have another function: function is_logged_in() { $is_logged_in=$this->session->userdata('is_logged_in'); if(!isset($is_logged_in)||$is_logged_in !=true) { echo 'You don\' have permission to access this page. <a href="../login">Login</a>'; die(); } } and works great. I define my session variables here: if($query) { $data=array( 'username'=>$this->input->post('username'), 'is_logged_in'=>true ); $this->session->set_userdata($data); redirect('site/members_area'); }
[eluser]Kentus[/eluser]
i discover that my problems is in this code: <?php $user=$this->session->userdata('username'); echo $user;?> //$username=$this->session->userdata('username'); <div id="mainContent"> <div id="userPanel"> <h3>Account Details</h3> Wellcome: <?php $user?> </div> <!-- se inchide userPanel--> </div><!-- se inchide mainContent-->
[eluser]Unknown[/eluser]
it would be great to see updated tutorials on the codeigniter site although im sure at this point people have asked questions regarding these types of errors using the tutorials posted |
Welcome Guest, Not a member yet? Register Sign In |