'Bootstrap dropdown not working on include header php

I have two pages home.php and header.php now the header file has the the top navigation bar that is to be included in the home.php page.I used a bootstrap drop down in header.php and it is working fine but when I am including header.php in home.php the nav bar is appearing perfect but the dropdown is not working so please help.Here are my codes
header.php

<?php
if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 
if(isset($_SESSION['user']))
{
	$user=$_SESSION['user'];
}
?>
<!DOCTYPE HTML>
<html>
<head>
	<link rel="SHORTCUT ICON" href="images/icon/logo.ico">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" media="all" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	</head>
<body>
<?php
require_once("dbconnect.php");
$query="SELECT * FROM user WHERE email='{$user}'";
$result=mysqli_query($con,$query);
$row=mysqli_fetch_array($result);
$name=ucfirst($row[1]);
?>
	<!--Navigation bar-->
	<div class="navi">
	<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span> 
				</button>
				<div class="navbar-brand">&nbsp;&nbsp;&nbsp;Rankethon</div>
				<form role="search" class="navbar-form navbar-left">
			<div class="input-group">
						            <input type="text" class="form-control" placeholder="Search for friends.." size="50" id="query" name="search" value="">
							            <div class="input-group-btn">
						            <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-search"></span></button>
						            </div>
						        </div>
			</form>
			</div>
			<div class="collapse navbar-collapse" id="myNavbar">
				<ul class="nav navbar-nav navbar-right">
					<li><a href="#"><span class="glyphicon glyphicon-home" aria-hidden="true"></span><b> Home</b></a></li>
					<li><a href="#"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><?php echo "<b>$name</b>";?></a></li>
					<li><a href="#"><span class="glyphicon glyphicon-tags" aria-hidden="true"></span><b> Noifications</b></a></li>
					<li class="dropdown">
					<a id="dLabel" data-target="#" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
					<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
					<b>Account</b>
					<span class="caret"></span>
					<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dLabel">
					<li><a href="#" style="text-align:center"><b>Settings</b></a></li>
					<li><a href="#" style="text-align:center"><b>About Us</b></a></li>
					<li role="separator" class="divider"></li>
					<li><a href="logout.php" style="text-align:center"><strong>Logout</strong></a></li>
					</ul>
					</a>
					</li>
		</div>
	</nav>
</body>
</html>

home.php

<?php
if(!isset($_SESSION)) 
    { 
        session_start(); 
    } 
if(!(isset($_SESSION['user'])))
{
	header('location:logout.php');
}
?>
<!DOCTYPE HTML>
<html>
<head>
	<link rel="SHORTCUT ICON" href="images/icon/logo.ico">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" media="all" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
	<script> $(document).ready(function () { $('.dropdown-toggle').dropdown(); }); </script>
</head>
<body>
<?php
include("header.php");
?>
</body>
</html>


Solution 1:[1]

this happens because you markup is invalid, because you embed the html tag two times.

Regards, Patrick

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 perber