I am fairly new to PHP, and I have started working on a small project. I want my code to be organized, so I decided to include the file container.phtml in my index.php file. So when $page = 'login' it would include the login.css and login.phtml file. I want login.css to apply to login.phtml. Instead when I run the program login.css does not load or produce any error messages in the console. Does the login.css file only apply to container.phtml? What can I do differently while maintaining the way I want this to work?
EDIT: The $page variable tells index.php what file it should include. Example: $page = 'login'; That tell it to get the login.phtml file. Then, in container.phtml it will check to see if $page = 'login' and then will include login.css
index.php
<?php
if(!isset($_GET['page'])){
$page = 'home';
}else{
$page = $_GET['page'];
}
/* Fetch needed files. */
require_once 'app/paths.php';
require_once THEME_LAYOUT_PATH . 'container.phtml';
$pages = array(
'home',
'login',
'register'
);
$layoutPath = 'themes/neutron/layout/' . $page . '/' . $page . '.phtml';
if(in_array($page, $pages)){
require $layoutPath;
}else{
require 'themes/neutron/layout/404/404.phtml';
}
?>
container.phtml
<html>
<title>Neutron</title>
<link rel = "stylesheet" type = "text/css" href = "<?php ASSETS_PATH . 'css/bootstrap.min.css' ?>">
<link rel = "stylesheet" type = "text/css" href = "<?php ASSETS_PATH . 'js/bootstrap.min.js' ?>">
<link rel = "stylesheet" type = "text/css" href = "<?php ASSETS_PATH . 'js/jquery.min.js' ?>">
<?php
/* Include header, footer, etc */
require_once THEME_LAYOUT_PATH . 'partials/header.php';
require_once THEME_LAYOUT_PATH . 'partials/footer.php';
?>
<?php if($page == 'login'){ ?>
<link rel = "stylesheet" type = "text/css" href = "<?php ASSETS_PATH . 'css/login.css' ?>">
<?php } ?>
</html>
login.phtml
<div class="login-clean" style="background-color: rgb(255,255,255);">
<form method="post">
<h2 class="sr-only">Login Form</h2>
<div class="illustration"><i class="icon ion-ios-navigate" style="color: #4777f4;"></i></div>
<div class="form-group"><input class="border rounded form-control" type="email" name="email" placeholder="Username"></div>
<div class="form-group"><input class="border rounded form-control" type="password" name="password" placeholder="Password"></div>
<div class="form-group"><button class="btn btn-primary btn-block border rounded" type="submit" style="background-color: #4777f4;">Log In</button></div><a class="forgot" href="#">Forgot Password?</a></form>
</div>