How Do I add the download counter php into my loging page?

Hi all I’ve been working on a Loging script and also a download script, they both work seprately, but when I want to use the include function say for example

include ("demo.php");

and place it on to my secure print sections after when the user is loged in, it don’t seem to show.

The Loging Script:

<?php
ob_start("ob_gzhandler");
?>
<html>
<head>
<title>Login Page</title>
<link href="web work The Trees Group work/htdocs/applog/styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="web work The Trees Group work/htdocs/applog/script.js"></script>
</head>
<body bgcolor="white" style="color:gray">
<div id="container">
  <div align="center"> <img src="web work The Trees Group work/htdocs/applog/img/header.jpg" width="800" height="119">
    <form action="web work The Trees Group work/htdocs/applog/index.php" method=get>
      <h1 align="center" style="color:black" ><font face="Arial, Helvetica, sans-serif">Welcome</font></h1>
      <?php
session_start(); 
if( $_SESSION["logging"]&& $_SESSION["logged"])
{
     print_secure_content();
}
else {
    if(!$_SESSION["logging"])
    {  
    $_SESSION["logging"]=true;
    loginform();
    }
       else if($_SESSION["logging"])
       {
         $number_of_rows=checkpass();
         if($number_of_rows==1)
            {    
             $_SESSION[user]=$_GET[userlogin];
             $_SESSION[logged]=true;
             print"<h1>you have loged in successfully</h1>";
             print_secure_content();
            }
            else{
                   print "wrong pawssword or username, please try again";
                loginform();
            }
        }
     }
     
function loginform()
{
print "&nbsp;please enter your login information to proceed with our site";
print ("<table border='0'><tr><td>username</td><td><input type='text' name='userlogin' size'20'></td></tr><tr><td>password</td><td><input type='password' name='password' size'20'></td></tr></table>");
print "<input type='submit' >";    
}

function checkpass()
{
$servername="localhost";
$username="username";
$password="password";
$conn=  mysql_connect($servername,$username,$password)or die(mysql_error());
mysql_select_db("database_name",$conn);
$sql="select * from table where name='$_GET[userlogin]' and password='$_GET[password]'";
$result=mysql_query($sql,$conn) or die(mysql_error());
return  mysql_num_rows($result);
}

function print_secure_content()
{
    print("<b><h1>hi mr.$_SESSION[user]</h1>");
    print "<br><a href='demo.php'>applications</a><br>";
    print "<br><h2>only a logged in user can see this</h2><br><a href='logout.php'>Logout</a><br>";

    
    
}
?>
    </form>
  </div>
  <div id="footer"> <font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="2"></font> </div>
</div>
</body>
</html>

The Download counter script:

<?php

// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the DB connection file:
require 'web work The Trees Group work/htdocs/counter/connect.php';

$extension='';
$files_array = array();


/* Opening the thumbnail directory and looping through all the thumbs: */

$dir_handle = @opendir($directory) or die("There is an error with your file directory!");

while ($file = readdir($dir_handle)) 
{
    /* Skipping the system files: */
    if($file{0}=='.') continue;
    
    /* end() returns the last element of the array generated by the explode() function: */
    $extension = strtolower(end(explode('.',$file)));
    
    /* Skipping the php files: */
    if($extension == 'php') continue;

    $files_array[]=$file;
}

/* Sorting the files alphabetically */
sort($files_array,SORT_STRING);

$file_downloads=array();

$result = mysql_query("SELECT * FROM download_manager");

if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
    /*     The key of the $file_downloads array will be the name of the file,
        and will contain the number of downloads: */
        
    $file_downloads[$row['filename']]=$row['downloads'];
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Download Counter</title>

<link rel="stylesheet" type="text/css" href="web work The Trees Group work/htdocs/counter/styles.css" />
<link rel="stylesheet" type="text/css" href="web work The Trees Group work/htdocs/counter/fancybox/jquery.fancybox-1.2.6.css" media="screen" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="web work The Trees Group work/htdocs/counter/script.js"></script>

</head>

<body>
<div id="">

    <ul class="manager">
    <?php 

        foreach($files_array as $key=>$val)
        {
            echo '<li><a href="download.php?file='.urlencode($val).'">'.$val.' 
                    <span class="download-count" title="Times Downloaded">'.(int)$file_downloads[$val].'</span> <span class="download-label">download</span></a>
                    </li>';
        }
    
    ?>
  </ul>

</div>
</body>
</html>

As you can see I have added the download counter as a hyperlink where really I would like to integrate the funtions within the login script. So when loged in then the download manger will show.

Thanks in advance for any help.

Kind Regards

nubreed