Click here to Skip to main content
12,063,452 members (74,992 online)

wayten asked:

Open original thread
Hi,

I have been unsuccessful with getting a static .php page to run on my local wamp server.

Here are my steps according to code igniter:
1. Unzip the package.
2. Copy the CodeIgniter folders and files to my local server directory
3. Go into the application folder of code igniter ( application/config/config.php)and set my base url to http://cns_projects.com using notepad++

4. I create a file named pages.php at application/controllers/pages.php in the code igniter folder with the following code
<?php
             class Pages extends CI_Controller {
 
    public function view($page = 'home')
    {
      if (!file_exists('application/views/pages/'.$page.'.php'))
 
         //Whoops, we don't have a page for that!
         show_404()
 
    }
 
      $data['title] = ucfirst($page); //Capitalize the first letter
      $this->load->view('templates/header', $data);
      $this->load->view('pages/'.$page, $data);
      $this->load->view('templates/footer', $data);
 
}

5. I create a header.php file in the code igniter folder at application/views/templates/header.php with following code:

<html>
<head>
	<title><?php echo $title ?> - CodeIgniter 2 Tutorial</title>
</head>
<body>
	<h1>CodeIgniter 2 Tutorial</h1>

6. Create the footer in the same template folder located in the code igniter folder at application/views/templates/footer.php
&copy; 2011	
</body>
</html>

7. I entered in my web address: http://cns_projects.com/index.php/pages/view/ to see a page I created called home.php.
I got a message which says access is forbidden. Error 403.


What is I have done wrong in setting up Code Igniter so that when I create my .php file in the view I'm able to enter the url to access it.

Any help would be much appreciated. Thanks much.

Wayten
Tags: PHP

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.160204.4 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100