directory/file structure for using INCLUDES function

Hi all,
I am a a student … I have been in PHP online class for 6 weeks and everything was going fine… now I am STUCK.
My assignment is to take on template, break it into index, header, and footer files, and use the includes function in the index file to attached header and footer files. I have to attach the css files as well.
My problem is the directory structure. The book says to: “Create an includes directory in the same file as index.php.” My school provides a webdocs section for students to use their server, so I put index in the webdocs via FTP then I made a folder while in webdocs called includes.php and put the header and footer files in that. Then I put the css file in the webdocs folder. When i go to my files online I only get the index file and it only shows the index page. I have changed the name of the includes file, and moved header and footer files inside and outside of includes file. I can’t figure out what I am doing wrong. I need a different wording for this sentence in the text “Create an includes directory in the same file as index.php” as file structuring is my weakness. THANK YOU in advance for your help.

The folder name should be simply “includes”

Post your code in index.php (be sure to use the forums php tags)

[php] <?php # Script 3.4 - index.php
$page_title = ‘Welcome to this site!’;
include (’/includes/header.html’);
?>

Content Header

  <p> This is where the page-specific content goes. This section, and the 
  corresponding header, will change from one page to the next. </p>
  
  <p> This is a where a bunch of text is put to fill in the screen with content. They use latin. I use blah, 
  blah, blah as this expression expresses so much so often, right? So, blah, blah, blah and so on and so forth. 
  So, blah, blah, blah and so on and so forth.So, blah, blah, blah and so on and so forth.   So, blah, blah, blah 
  and so on and so forth. So, blah, blah, blah and so on and so forth. So, blah, blah, blah and so on and so forth. 
  So, blah, blah, blah and so on and so forth.</p>
  
  <? php include ('includes/footer.html');
  ?>

[/php]
I hope this is the correct way to use the forums PHP code button??? As I understood it, as the textbook said, the Includes folder is a folder that I put header, and footer files in. It says to put this in the same folder as index.php. I am using dreamweaver. I have tried so many different ways of making this includes folder now, I am perplexed. Do I make the includes folder in dreamweaver site… or in the webdocs folder for the schools server?
THANK YOU a thousand times over.
Jaloney

So on your server you should have the following structure

/includes/header.html
/includes/footer.html
/index.php

I’m not entirely sure what problem you are having

I am sorry I am so dense. I have the files header, footer, index, and css on the server. BUT WHERE does the INCLUDES file go? In my site directory on dreamweaver or do I create an empty folder inside of server and put index and everything else in an empty INCLUDES folder that I create when I access the folder? It seems I have found a million ways to do this and none of them is the correct way… I tried making the file in my Dreamweaver site and also making the Includes file directly in the server… It can’t be that hard??? I hope.
Jaloney

“includes” is a directory not a file. It is simply a directory to hold your templates (header and footer). You create an empty file on your server called “includes”, then upload your header.html and footer.html file inside that folder. The index.php remains outside of that folder in the root.

I do not use dreamweaver so I can’t help you there.

Thank you for clarifying this Matt! The text in class did not make it at all clear.
:slight_smile: :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service