Subash
Subash

Reputation: 7256

Codeigniter doesn't load the view

I am new to Codeigniter but for some reason I can't get it working. What I am trying to do is very simple. I have a post.php file inside controller folder. Contents of post.php is as following:

    class Posts extends CI_Controller{
        function index(){
            $this->load->view('hello.php');
        }
    }

Then my hello.php file is inside views folder. It is just a static HTML page. Just trying to get it working first.

The folder structure is a follows: htdocs/codeignitor

I was expecting to get contents of hello.php when I visit:

http://localhost:8888/codeigniter/index.php/posts

When I visit the above url it says Page Not Found. But the default welcome page is working fine.

Upvotes: 0

Views: 5893

Answers (4)

dhpratik
dhpratik

Reputation: 1138

plz check the file-name it should be posts.php if ur class name is Posts and if this is correct then check the config.php for the $config['base_url'] and set ur site url properly.

Upvotes: 0

GautamD31
GautamD31

Reputation: 28763

Never use 'file extents' while using for loading: you suggetsed to use:

$this->load->view('hello');

that's it;

Upvotes: 1

Derek Nutile
Derek Nutile

Reputation: 211

Don't add the '.php' extension. Like this:

$this->load->view('hello');

Upvotes: 1

Viktors
Viktors

Reputation: 935

$this->load->view('hello');

Your files should be placed as follows:

htdocs
|
+-- codeignter
    |
    +-- application
        |
        +-- controllers
        |  |
        |  +-- posts.php
        +-- views
           |
           +-- hello.php

Upvotes: 6

Related Questions