Slight problem when embedding HTML inside PHP.
Problem #1
logon php page contains the form for user to login. With successful login, it brings up the user to the resume page.
In order to maintain the uniform design throughout all the pages on the site, the logon page contains the same logo and navigational menu that of the other pages.
Once user have successful login, it brings up the resume page with the same logo and menu.
However, the problem is that it is displaying the header twice!!
Here is an error:

Warning: Cannot modify header information - headers already sent by (output started at /www/zzl.org/a/m/i/amishra/htdocs/password_protect.php:8) in /www/zzl.org/a/m/i/amishra/htdocs/password_protect.php on line 166

Problem #2
In addition, the logon form is supposed to store cookies so user doesn't need to re-login every time when attempting to access the resume page but for some reason that functionality is not working.
I would greatly appreciate it someone can direct me to the right path.

You need to post your code (and please use code tags

...

Thank you for taking interest to help me with this issue.

First of all, this is the website:
http://amishra.zzl.org

If you go under the portfolio->resume it will prompt for logon:
Username: guest
Password: pass

This is the code I have before my XHTML code under the resume page.

<?php include("password_protect.php"); ?>

followed by XHTML and CSS that is the same information as password_protect.php code as listed below.
Even when logo and navigational menu are removed from the code, the original error as listed on previous post stays.

The following is the code from password_protect.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mishra's portfolio</title>

<link rel="stylesheet" type="text/css" href="base.css" media="screen" />
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/jquery.form.js"> </script>
<script type="text/javascript" src="js/cufon.js"></script>
<script src="js/ChunkFive.js" type="text/javascript"></script>
<script type="text/javascript">		
		Cufon.replace('h1,h2,h3',  {		
});

</script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript">
		// initialise plugins
		jQuery(function(){
			jQuery('ul.sf-menu').superfish();
			});
	$(function(){
			 $('#tweets').tweetable({username: 'themeforest', time: true, limit: 2});
			});
		</script>
<script type="text/javascript" src="js/jquery.tweetable.js"></script>
<script type="text/javascript">
	$(document).ready(function() { 
	var options = { target:'div#alert'}; 
	$('#contactForm').ajaxForm(options); });
		
	$.fn.clearForm = function() {
	  return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
		  return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
		  this.value = '';
		else if (type == 'checkbox' || type == 'radio')
		  this.checked = false;
		else if (tag == 'select')
		  this.selectedIndex = -1;
	  });
	};

</script>
<!--[if IE 6]>
<script type='text/javascript' src='js/DD_belatedPNG.js'></script>
<script>DD_belatedPNG.fix('img, png, gif, a, div, h3,p	');</script>
<link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" />
<![endif]-->
</head>
<body>
<div class="container container_12">
  <div class="grid_4">
    <h1 class="logo"> <a href="index.html"><img src="images/logo.png" alt="alpha" /></a></h1>
  </div>
  <div class="grid_8">
    <ul class="sf-menu">
      <li ><a href="index.html">Home</a></li>
      <li> <a href="about-me.html">About Me </a> </li>
      <li> <a href="portfolio.html">Portfolio </a>
        <ul>
          <li class="current"> <a href="resume.php">Resume</a></li>
          <li class="current"> <a href="courseworks.html">Courseworks</a></li>
          <li> <a href="works.html">Recent works</a></li>
        </ul>
      </li>
      <li> <a href="blog.html">Blog </a> </li>
      <li class="current"> <a href="contact-me.html">Contact Me </a> </li>
    </ul>
  </div>
  <div class='clear'>&nbsp;</div>
<div class="harizontal-divider"></div>

<?php

$LOGIN_INFORMATION = array(
  'guest' => 'homerun'
);

// request login? true - show login and password boxes, false - password box only
define('USE_USERNAME', true);

// User will be redirected to this page after logout
define('LOGOUT_URL', 'http://www.example.com/');

// time out after NN minutes of inactivity. Set to 0 to not timeout
define('TIMEOUT_MINUTES', 0);

// This parameter is only useful when TIMEOUT_MINUTES is not zero
// true - timeout time from last activity, false - timeout time from login
define('TIMEOUT_CHECK_ACTIVITY', true);


if(isset($_GET['help'])) {
  die('Include following code into every page you would like to protect, at the very beginning (first line):<br>&lt;?php include("' . str_replace('\\','\\\\',__FILE__) . '"); ?&gt;');
}

// timeout in seconds
$timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);

// logout?
if(isset($_GET['logout'])) {
  setcookie("verify", '', $timeout, '/'); // clear password;
  header('Location: ' . LOGOUT_URL);
  exit();
}

if(!function_exists('showLoginPasswordProtect')) {

// show login form
function showLoginPasswordProtect($error_msg) {
?>
<html>
<head>
  <title>Mishra's portfolio</title>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</head>
<body>
  <style>
    input { border: 1px solid black; }
  </style>
  <div style="width:500px; margin-left:auto; margin-right:auto; text-align:center">
  <form method="post">
    <h2>This <span>page</span> requires <strong>logon!</strong></h2>
    <font color="red"><?php echo $error_msg; ?></font><br />
<?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?>
    <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" />
  </form>
  <br />
 <a href="mailto:amishraa@gmail.com?subject=Mishra's portfolio: Access request">Request access</a></h4>
  </div>

<div class='clear'>&nbsp;</div>
  <div class="harizontal-divider"></div>
  <div class="grid_12">
    <div class="grid_6 alpha">
      <p>Copyright © Mishra's portfolio, all rights reserved. </p>
    </div>
  </div>
</div>
</body>
</html>

<?php
  // stop at this point
  die();
}
}

// user provided password
if (isset($_POST['access_password'])) {

  $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  $pass = $_POST['access_password'];
  if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
  || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) 
  ) {
    showLoginPasswordProtect("Incorrect password.");
  }
  else {
    // set cookie if password was validated
    setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
    
    // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
    // So need to clear password protector variables
    unset($_POST['access_login']);
    unset($_POST['access_password']);
    unset($_POST['Submit']);
  }

}

else {

  // check if password cookie is set
  if (!isset($_COOKIE['verify'])) {
    showLoginPasswordProtect("");
  }

  // check if cookie is good
  $found = false;
  foreach($LOGIN_INFORMATION as $key=>$val) {
    $lp = (USE_USERNAME ? $key : '') .'%'.$val;
    if ($_COOKIE['verify'] == md5($lp)) {
      $found = true;
      // prolong timeout
      if (TIMEOUT_CHECK_ACTIVITY) {
        setcookie("verify", md5($lp), $timeout, '/');
      }
      break;
    }
  }
  if (!$found) {
    showLoginPasswordProtect("");
  }

}

?>

I am also posting the source code for resume page which is as follows:

<?php include("password_protect.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mishra's portfolio</title>

<link rel="stylesheet" type="text/css" href="base.css" media="screen" />
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/cufon.js"></script>
<script src="js/ChunkFive.js" type="text/javascript"></script>
<script type="text/javascript">		
		Cufon.replace('h1,h2,h3',  {		
});

</script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript">
		// initialise plugins
		jQuery(function(){
			jQuery('ul.sf-menu').superfish();
			});
	$(function(){
			 $('#tweets').tweetable({username: 'themeforest', time: true, limit: 2});
			});
		</script>
<script type="text/javascript" src="js/jquery.tweetable.js"></script>
<!--[if IE 6]>
<script type='text/javascript' src='js/DD_belatedPNG.js'></script>
<script>DD_belatedPNG.fix('img, png, gif, a, div, h3,p	');</script>
<link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" />
<![endif]-->
<!-- 
</head>
<body>
 -->
<!-- 
<div class="container container_12">
  <div class="grid_4">
    <h1 class="logo"> <a href="index.html"><img src="images/logo.png" alt="alpha" /></a></h1>
  </div>
  <div class="grid_8">
    <ul class="sf-menu">
      <li ><a href="index.html">Home</a></li>
      <li> <a href="about-me.html">About Me </a> </li>
      <li> <a href="portfolio.html">Portfolio </a>
        <ul>
          <li class="activelink"> <a href="resume.php">Resume</a></li>
          <li class="current"> <a href="courseworks.html">Courseworks</a></li>
          <li> <a href="works.html">Recent works</a></li>
        </ul>
      </li>
      <li> <a href="blog.html">Blog </a> </li>
      <li class="last-link"> <a href="contact-me.html">Contact Me </a> </li>
    </ul>
  </div>
  <div class='clear'>&nbsp;</div>
<div class="harizontal-divider"></div>
 -->
  <div class="grid_12" id="main-tagline">
    <h2> This is the most recent <span>resume</span> providing information on my <strong>career path</strong> and my <strong>goals.</strong></h2>
  </div>
  <div class='clear'>&nbsp;</div>
<div class="harizontal-divider"></div>
  <!--content column-->
  <div class="grid_8" id="content-column">
    <h2>Professional Profile</h2>

    <h3>Experience</h3>

    <h3>Education and Credentials</h3>

    </ul>
    <p></p>
  </div>
  <!--/content column-->
  <!--sidebar-->
  <div class="grid_4" id="sidebar">
     <div class="sidebar"> 
      <ul class="contact-details">
        <li>
        <h2> Archive</h2>
        <p><strong><a href="docs/resume1.pdf" class="view-more2" target=_blank>Download PDF</a></p>
        </li>
        <li>
          <h2> Contact Details</h2>
          <h4><strong>Ashish Mishra</strong></h4>
          <h4><strong>Phone :</strong> 757 - 745 - 3436</h4>
          <h4><strong>Fax :</strong> 757 - 555 - 1212</h4>
          <h4><strong>Email:</strong> <a href="mailto:amishraa@gmail.com?subject=Message from Mishra's portfolio">amishraa@gmail.com</a></h4>
          <h4><strong>Address:</strong> <br />
            Chesapeake, Virginia, USA</h4>
        </li>
      </ul>
    
    </div>
  </div>
  <!--/sidebar-->
  <div class='clear'>&nbsp;</div>
  <!--
<div class="harizontal-divider"></div>
  <div id="bottom">
    <div class="grid_12" >
      <h2> My areas of interest include....</h2>
      <div class="grid_4 alpha">
        <h3> System Analysis</h3>
        <p><a href="sys-analysis.html"> View More &raquo;</a></p>
      </div>
      <div class="grid_4">
        <h3>Database Development</h3>
        <p><a href="dbdev.html"> View More &raquo;</a></p>
      </div>
      <div class="grid_4 omega">
        <h3>Application Development</h3>
        <p><a href="appdev.html"> View More &raquo;</a></p>
      </div>
    </div>
  </div>
  -->
  <!--/bottom-->
  <div class='clear'>&nbsp;</div>
  <div class="harizontal-divider"></div>
  <div class="grid_12">
    <div class="grid_6 alpha">
      <p>Copyright © Mishra's portfolio, all rights reserved. </p>
    </div>
  </div>
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.