PHP Problem with IIS 7.5

I am going through a e-commerce tutorial.  It is apparent that it is not seeing the code in the header.html file which is in the includes folder. I am able to register with the site.  That file is in the root and it is register.php so it is not a connection issue.  After I have registered it is supposed to limit the choices in the header file.  Even though I am registered the admin options also show which is incorrect.  I am running IIS 7.5 and MySQL is the database.  

Can this be an issue with PHP and IIS?      

Header file
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><?php // Use a default page title if one wasn't provided...
	if (isset($page_title)) { 
			echo $page_title; 
	} else { 
			echo 'Knowledge is Power: And It Pays to Know'; 
	} 
	?></title>

	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/sticky-footer-navbar.css" rel="stylesheet">

  </head>

  <body>

    <!-- Wrap all page content here -->
    <div id="wrap">

      <!-- Fixed navbar -->
      <div class="navbar navbar-fixed-top">
        <div class="container">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.php">Knowledge is Power</a>
          <div class="nav-collapse collapse">
            <ul class="nav navbar-nav">
<?php // Dynamically create header menus...

// Array of labels and pages (without extensions):
$pages = array (
	'Home' => 'index.php',
	'About' => '#',
	'Contact' => '#',
	'Register' => 'register.php'
);

// The page being viewed:
$this_page = basename($_SERVER['PHP_SELF']);

// Create each menu item:
foreach ($pages as $k => $v) {

	// Start the item:
	echo '<li';

	// Add the class if it's the current page:
	if ($this_page == $v) echo ' class="active"';

	// Complete the item:
	echo '><a href="' . $v . '">' . $k . '</a></li>
	';

} // End of FOREACH loop.

// Show the user options:
if (isset($_SESSION['user_id'])) {

	// Show basic user options:
	// Includes references to some bonus material discussed in Part Four!
	echo '<li class="dropdown">
	<a href="#" class="dropdown-toggle" data-toggle="dropdown">Account <b class="caret"></b></a>
		<ul class="dropdown-menu">
			<li><a href="logout.php">Logout</a></li>
			<li><a href="renew.php">Renew</a></li>
			<li><a href="change_password.php">Change Password</a></li>
			<li><a href="favorites.php">Favorites</a></li>
			<li><a href="recommendations.php">Recommendations</a></li>
		</ul>
	</li>';

	// Show admin options, if appropriate:
	if (isset($_SESSION['user_admin'])) {
		echo '<li class="dropdown">
		<a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>
			<ul class="dropdown-menu">
				<li><a href="add_page.php">Add Page</a></li>
				<li><a href="add_pdf.php">Add PDF</a></li>
				<li><a href="#">Something else here</a></li>
			</ul>
		</li>';		
	}
	
} // user_id not set.

?>
            </ul>
          </div><!--/.nav-collapse -->
        </div><!--/container-->
      </div><!--/navbar-->

      <!-- Begin page content -->
      <div class="container">
	
		<div class="row">
			
			<div class="col-3">
				<h3 class="text-success">Content</h3>
			<div class="list-group">
<?php // Dynamically generate the content links:
$q = 'SELECT * FROM categories ORDER BY category';
$r = mysqli_query($dbc, $q);
while (list($id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)) {
	echo '<a href="category.php?id=' . $id . '" class="list-group-item" title="' . $category . '">' . htmlspecialchars($category) . '
	</a>';
}
?>
			  <a href="pdfs.php" class="list-group-item" title="PDFs">PDF Guides
			  </a>
			</div><!--/list-group-->

<?php // Should we show the login form?
if (!isset($_SESSION['user_id'])) {
	require('login_form.inc.php');
}
?>
			</div><!--/col-3-->
		  
			
		  <div class="col-9">
			<!-- CONTENT -->

Open in new window



Index.php

<?php
// This file is the home page. 
// This script is begun in Chapter 3.

// Require the configuration before any PHP code as the configuration controls error reporting:
require('./includes/config.inc.php');
// The config file also starts the session.

// To test the sidebars:
$_SESSION['user_id'] = 1;
$_SESSION['user_admin'] = false;
$_SESSION['user_not_expired'] = true;
//$_SESSION=array();

// Require the database connection:
require(MYSQL);

// Next block added in Chapter 4:
// If it's a POST request, handle the login attempt:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	include('./includes/login.inc.php');
}

// Include the header file:
include('./includes/header.html');

/* PAGE CONTENT STARTS HERE! */
?><h1>Welcome</h1>
 <p class="lead">Welcome to Knowledge is Power, a site dedicated to keeping you up-to-date on the Web security and programming information you need to know. Blah, blah, blah. Yadda, yadda, yadda.</p>
	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur volutpat nunc, eget vulputate quam tristique sit amet. Donec suscipit mollis erat in egestas. Morbi id risus quam. Sed vitae erat eu tortor tempus consequat. Morbi quam massa, viverra sed ullamcorper sit amet, ultrices ullamcorper eros. Mauris ultricies rhoncus leo, ac vehicula sem condimentum vel. Morbi varius rutrum laoreet. Maecenas vitae turpis turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce leo turpis, faucibus et consequat eget, adipiscing ut turpis. Donec lacinia sodales nulla nec pellentesque. Fusce fringilla dictum purus in imperdiet. Vivamus at nulla diam, sagittis rutrum diam. Integer porta imperdiet euismod.</p>

<h3>Lorem Ipsum</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent consectetur volutpat nunc, eget vulputate quam tristique sit amet. Donec suscipit mollis erat in egestas. Morbi id risus quam. Sed vitae erat eu tortor tempus consequat. Morbi quam massa, viverra sed ullamcorper sit amet, ultrices ullamcorper eros. Mauris ultricies rhoncus leo, ac vehicula sem condimentum vel. Morbi varius rutrum laoreet. Maecenas vitae turpis turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce leo turpis, faucibus et consequat eget, adipiscing ut turpis. Donec lacinia sodales nulla nec pellentesque. Fusce fringilla dictum purus in imperdiet. Vivamus at nulla diam, sagittis rutrum diam. Integer porta imperdiet euismod.</p>

<?php /* PAGE CONTENT ENDS HERE! */

// Include the footer file to complete the template:
include('./includes/footer.html');
?>

Open in new window

JohnMac328Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Without running through your entire code, the one thing that jumps out at me is this line:

// Include the header file:
include('./includes/header.html');

Open in new window


Your header file seem to contain a lot of PHP so I would assume it has the PHP extension. Your code might need to look like this:

// Include the header file:
include('./includes/header.php');

Open in new window

JohnMac328Author Commented:
I tried that but no difference.  On the authors web forum nobody else is having the same problems I am and the files are from the book in completed form.  He responded and does not know why it is not working.
Chris StanyonWebDevCommented:
OK. I'm surprised the a file with an html extension is being parsed by PHP but if you say it is, then it is.

Add these 2 lines right at the very top of your index file. It will turn on error reporting and may give you some additional info:

error_reporting(E_ALL);
ini_set('display_errors', 1);

Open in new window


Another thing to try is to view the source of the page from your browser - this will show the code that's been generated after the PHP parser has done it's bit - again, it might shed some light on it.

If you can post a link to your page, we might be able to help some more.
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

JohnMac328Author Commented:
The live site

http://www.rangercreekweb.com/ecommerce2/index.php

When you go to register and then click on Login - it gives a strange error but not when I try it locally
Chris StanyonWebDevCommented:
Right - it is a problem with your header.html file. Because it includes PHP and you've given it an extension of HTML, the PHP never get's parse - it just gets output as text - call the header.html file in your browser and you'll see what I mean - you need to change the extension to php and update the include line in your index.php file
JohnMac328Author Commented:
Makes sense - if this was a Linux system would it still make a difference?  My point is why send the completed source files like this if it is not going to work
Chris StanyonWebDevCommented:
Generally it wouldn't work in Linux either - by default, PHP code will only be parsed if the file extension is 'php'. There are ways around it but they're not recomended. If you include php code, then set the extension to php.

Can't comment on why the files are the way they are - maybe you've mis-read something, or named a file with HTML instead of PHP. Maybe the tutorial's wrong, or someone, somewhere's made a mistake - it happens :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnMac328Author Commented:
Ok - thanks for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.