Hi all. Been trying to get this to work for a few days, to no avail. First, I have a user login on index.php. Then, they get redirected to audio3.php. Redirect works fine, BUT, I want that page to display files in the audio/username folder. I can't get the username from login page to carry over to audio page in "insert" where called for. I tried adding a field to the DB called userfolder and replaced username with that to no avail. New to php so the code may not look pretty.
Here is a portion of the code from the audio3.php page:
<?php
session_start();
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
$tbl_name="authorize"; // Table name
//require the config file
require ("/home/zackpowe/public_html/downloads/config.php");
require ("/home/zackpowe/public_html/downloads/functions.php");
// Connect to server and select databse.
mysql_connect("$server", "$dbusername", "$dbpassword")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
// Some functions
/**
* Get the contents of a directory.
* returns the contents in an array or false
* on completion.
*/
function getDirFiles($dirPath)
{
// if the passed var isn't a dir
if(!is_dir($dirPath))
{
// if debugging
echo 'Error: var is not a dir.';
return false;
}
// if we can't open the dir
if (!$handle = opendir($dirPath))
{
// if debugging
echo 'Error: can not open dir.';
return false;
}
while (false!== ($file = readdir($handle)))
{
if ($file!= "." && $file!= "..")
{
$filesArr[] = trim($file);
}
}
closedir($handle);
sort($filesArr);
reset($filesArr);
return($filesArr);
}
while($row = mysql_fetch_array($result));
$downloadPath = "/home/zackpowe/public_html/downloads/";
$audioPath = $downloadPath ."audio/";
$path = $audioPath . $row['username']. "/";
$file_list = getDirFiles($path);
{
$file_list = getDirFiles("/home/zackpowe/public_html/downloads/audio/" . $row['username'] . "/");
$count = count($file_list);
?>