Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sub Folders and PHP Pages....

Featured Replies

Hi! I am novice when it come's to Webdesign, so please forgive me if I come across as a little unlearned. 

In my Directory Root File, I had created, amongst the typical, images folder, css folder and scripts folder and etc, an pages folder. I created the pages folder for the the purpose of keeping my files well organized. I have created both the 'Index . php' and 'contact . php', so far running both on my localhost is working like a charm. But when I tried to place the 'contact . php ' page in the pages folder, I am unable to link to it from my 'index . php' page. I get the following error:

Quote

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

I should add that I created a 'header. php' and 'footer.php, placing them in an includes folder.  I had placed a link to the 'contact . php' page' in my 'footer. php' include file. It looks as follows: 

Quote

   <footer>
         <a href="pages/contact.php">Contact</a>
      </footer>
   </body>
</html>

Also, here is my 'header . php ' include file:

Quote

<!DOCTYPE html>
<html lang="en" dir="ltr">
   <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title><?php echo "$pagetitle";?></title>
      <meta name="description:" content="X">
      <meta name="keywords:" content="X">
      <link rel="stylesheet" href="build/styles/normalize.css">
      <link rel="stylesheet" href="build/styles/global.css">
   </head>
   <body>
      <nav>
         <ul>
            <li><a href="index.php">Home</a></li>
         </ul>
      </nav>

And my 'index . php' page:

Quote

<?php
   $pagetitle = "Home";
   include "inc/header.php";
 ?>

 <?php
   include "inc/footer.php";
 ?>
 

My question is, am I NOT allowed to place the 'contact . php' and others, inside a sub folder within the root? And if I can, how can I link to it? 

 

Thank you!

  • Jo 90 changed the title to Sub Folders and PHP Pages....

You can place the files where ever you want you just need to reference them correctly. If you are in the same folder then you don't need anything in front of the file name i.e. "index.php" or "contact.php". If you had a sub folder called products in you pages folder and you wanted to reference your contact.php file you would use "/pages/contact.php". The / takes you back to the top of the tree. You can also use "../contact.php" which take you up one level.

Hope that helps.

Edited by nahosting
typo

  • Author
16 minutes ago, nahosting said:

You can place the files where ever you want you just need to reference them correctly. If you are in the same folder then you don't need anything in front of the file name i.e. "index.php" or "contact.php". If you had a sub folder called products in you pages folder and you wanted to reference your contact.php file you would use "/pages/contact.php". The / takes you back to the top of the tree. You can also use "../contact.php" which take you up one level.

Hope that helps.

Thank you for your advice, BUT! 

Quote

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

I get the same result. 

 

Your advice: 

Quote

<footer>
         <a href="../contact.php">Contact</a>
      </footer>
   </body>
</html>

And I tried it this way too:

Quote

<footer>
         <a href="pages/contact.php">Contact</a>
      </footer>
   </body>
</html>

Still didn't work.

Or maybe It’s because /pages/ isn’t a folder in /inc/

Try: href=“./pages/contact.php”

Or just move the included to the top level folder.

Edited by fisicx

  • Author

I used pages, but accidentally put page, but it was pages.

 

now i'm getting this:

 

http://localhost/project01/pages/contact.php

Quote

Warning: include(inc/header.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project01\pages\contact.php on line 3

Warning: include(): Failed opening 'inc/header.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project01\pages\contact.php on line 3

Warning: include(inc/footer.php): failed to open stream: No such file or directory in C:\xampp\htdocs\project01\pages\contact.php on line 7

Warning: include(): Failed opening 'inc/footer.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\project01\pages\contact.php on line 7

  

You need to use "/inc/header.php" as just inc/header.php is then expecting the inc directory to be in the pages directory.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.