Click here to Skip to main content
15,895,833 members

Code Igniter with WAMP Server to run PHP application

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
<?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
<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
HTML
© 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

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

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.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900