Ne Kr Ne Kr - 1 month ago 11
PHP Question

including a header with subfolder

I have some big problems including my header in subfolder. I have a folder structure like this:

Folder structure

I would like to include my header in the innovatian-project.php. As I see it, I have to go back three folders to get to the root:


AU -> Courses -> Document Root


I have tried with the following:


  • <?php include '../../../resources/includes/header.php'?>

  • <?php include(__DIR__.'/resources/includes/header.php'); ?>

  • <?php include($_SERVER['DOCUMENT_ROOT'].'/header.php'); ?>

  • <?php include($_SERVER['DOCUMENT_ROOT'].'/resources/includes/header.php'); ?>

  • <?php include('../../resources/includes/header.php'); ?>



But none of this is working. I have tried so many things, that I cannot even remember anymore. Does anybody have an idea on what I can do? The path to the innovation-project is here:

Portfolio

<?php include 'resources/includes/header.php' ?>

<body id="services">

<?php include 'resources/includes/navbar.php' ?>

<!-- start intro section -->
<section class="intro">
<div class="container">
<div class="row">

<div class="col-md-12 text-center">
<div class="intro-content">
<h1>Mine kompetencer <strong>strongest </strong></h1>
<h2>areas, where I can add the most value to a company </h2>

Mine kompetencer er baseret på
</div>
</div>
</div>
</div>
</section>
<!-- end intro section -->


UPDATE

When I use the following code, the header, nav and footer is called. But the CSS is not called:

<?php include $_SERVER['DOCUMENT_ROOT'] . '/Portfolio_da/resources/includes/header.php' ?>

<body id="services">

<?php include $_SERVER['DOCUMENT_ROOT'] . '/Portfolio_da/resources/includes/navbar.php' ?>

<!-- start intro section -->
<section class="intro">
<div class="container">
<div class="row">

<div class="col-md-12 text-center">
<div class="intro-content">
<h1>Mine kompetencer <strong>strongest </strong></h1>
<h2>areas, where I can add the most value to a company </h2>

Mine kompetencer er baseret på
</div>
</div>
</div>
</div>
</section>
<!-- end intro section -->

<?php include $_SERVER['DOCUMENT_ROOT'] . '/Portfolio_da/resources/includes/footer.php' ?>


UPDATE 2 WHERE I CALL THE CSS IN header.php

<!DOCTYPE HTML>
<html lang="en">
<head>

<!-- Meta Data -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Developed By Vouzalis Design">
<meta name="author" content="Vouzalis Design">
<meta name="keywords" content="Marketing automation, content quality websites, webdesign 2016, wireframing, Landingpage">

<!-- Favicon -->
<link rel="shortcut icon" href="images/favicon.ico">

<title>Vouzalis Creative Portfolio</title>

<!-- Stylesheets -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/owl.theme.css">
<link rel="stylesheet" href="css/owl.carousel.css">
<link rel="stylesheet" href="css/supersized.css">
<link rel="stylesheet" href="css/nivo-theme.css">
<link rel="stylesheet" href="css/nivo-lightbox.css">

<!-- Main Stylsheets -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsive.css">
<!-- Theme Color Stylesheet -->
<link rel="stylesheet" href="css/theme_color.css">

<!-- Google Font -->
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700' rel='stylesheet' type='text/css'>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<?php include_once("analyticstracking.php") ?>

</head>


enter image description here

Answer
  1. <?php include($_SERVER['DOCUMENT_ROOT'].'/resources/includes/header.php'); ?>

  2. See your php.ini about

allow_url_include

  1. What is in your router file?

  2. You have to go up 2 folders.

    <?php include('../../resources/includes/header.php'); ?>

UPDATE

Change these lines in header.php: <link rel="stylesheet" href="css/bootstrap.min.css">

like <link rel="stylesheet" href="http://<?php echo $_SERVER['HTTP_HOST'] ?>/Portfolio_da/css/bootstrap.min.css">