Hi all I am in need to of some help. As I just sorted out a loging scritp to. I can't seem to add a downloading counter within the members page. So say for example after when the user logs and then wants to view the speacial page the download counter should appear but it is not apperaing and need to some help intgrating it. The code shown below.

This is the page that comes up after when the user has loged in.

<?php
session_name('tzLogin');
session_set_cookie_params(2*7*24*60*60);
session_start();
?>
<!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>Partners Area</title>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
</head>
<body>
<div id="main">
  <div class="container">
    <h1>Partners Area</h1>
    <h2>Login to view this resource!</h2>
  </div>
  <div class="container">
    <?php

	if($_SESSION['id'])
	echo '<h1>Hello, '.$_SESSION['usr'].'! You are logged in!</h1>';
	else echo '<h1>Please, <a href="demo.php">login</a> and come back later!</h1>';
    
    ?>
  </div>
  <div class="container tutorial-info"> Please click here to return back to the main page to logout <a href="http://www.sumwebsite.org.uk/logster/demo.php" target="_self">Main Partners Page</a>.</div>
</div>
</body>
</html>

I want to integrate this page within the above code:

<?php

error_reporting(E_ALL^E_NOTICE);

require 'connectdm.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></title>

<link rel="stylesheet" type="text/css" href="dm.css" />
<link rel="stylesheet" type="text/css" href="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="script.js"></script>

</head>

<body>
<div id="file-manager">

    <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>

Anyhelp would be good and much apprecieated.

Kind Regards

Bow103

first you need start session in everybody page.

remember, is it just example. dont using this code in realy site. only for test.
index.php

<?php
@session_name('tzLogin');
@session_set_cookie_params(2*7*24*60*60);
@session_start();
?>
<!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>Partners Area</title>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
</head>
<body>
<div id="main">
  <div class="container">
    <h1>Partners Area</h1>
    <h2>Login to view this resource!</h2>
  </div>
  <div class="container">
    <?php

    if( isset( $_GET['submit'] ) )
    {
    	//User Click Login
    	$_SESSION['id'] = 123;
    }
    if($_SESSION['id'])
    {
    	echo '<h1>Hello, '.$_SESSION['usr'].'! You are logged in!</h1>';
    	echo '<br>Go to <a href="download.php">download page</a>';
    }
    else
    	echo '<h1>Please, <a href="index.php?submit=yes">clicke here</a> for login!</h1>';
    
    ?>
  </div>
  <div class="container tutorial-info"> Please click here to return back to the main page to logout <a href="http://www.sumwebsite.org.uk/logster/demo.php" target="_self">Main Partners Page</a>.</div>
</div>
</body>
</html>

download.php

<?php
@session_name('tzLogin');
@session_set_cookie_params(2*7*24*60*60);
@session_start();
?>
<!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>Partners Area</title>
<link rel="stylesheet" type="text/css" href="demo.css" media="screen" />
</head>
<body>
<div id="main">
  <div class="container">
    <h1>Partners Area</h1>
    <h2>Login to view this resource!</h2>
  </div>
  <div class="container">
    <?php

    if($_SESSION['id'])
    {
    	echo '<h1>Hello, '.$_SESSION['usr'].'! You are logged in!</h1>';
    	echo '<br>Select file you need...';
    	/* ... */
    }
    else
    	echo '<h1>Please, <a href="index.php?submit=yes">clicke here</a> for login!</h1>';
    
    ?>
  </div>
  <div class="container tutorial-info"> Please click here to return back to the main page to logout <a href="http://www.sumwebsite.org.uk/logster/demo.php" target="_self">Main Partners Page</a>.</div>
</div>
</body>
</html>

now, you select in Data Base (or file system) filelist and show user for choice. If user click of file name, you need create new script where you give counter value, increase him and save.

PS: sorry for my english...

I'm have very much solutions for this task

Hi thanks for the help but on line 36 on the download.php what would I need to put in?

kind regards

bow103

if you wont, i'm create this project. Me need 2-3 day(s). but i'm make another Data Base structure, maybe we need to talk more on ICQ -288394245 or somewhere else. You need a complete code, i'm dont wont to show it this. Here is job, i'm helping you for free. Just write message and this link. ok?

I have also tryed this;

echo file_get_contents("dm.php");

but i get an error or shows some php code

# $val) { echo ''.$val.' '.(int)$file_downloads[$val].' download
'; } ?>

file_get_contents return text anybody file, what result you would get?

if you see the open page in browser, this is normal.
if this you see in "Sorce Code Page" in browser, is it very bad.
I think what you see in first method...

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.