Jump to content

Downloads.php file should display a specific folder assigned to a username


karthiksrinivas

Recommended Posts

Hello

 

My question is.. After a User is logged in he would be displayed with different menus like changepassword logout downloads etc. after clicking downloads it should display the contents of the directory that is assigned to the user

 

example

if tthe username is TEST

in the server the directory structure /public_html/downloads/test/

 

when the user logs in and clicks the downloads file it should display the contents of Test folder

 

please help me.

<?php
  $time = time();

  // Check if there is a cookie, if there isn't then exit!
  if (!isset($_COOKIE['cookie_info'])) {
      echo "Cannot access this page: You aren't logged in";
      exit;
  }

  // If there is a cookie, validate the cookie
  else {

      // Use Connect Script
      include("connect.php");

      // Include the validation of user file
      include("validateuser.php");

      // If user and password are correct
      if (validateuser() == true) {

          // Use cookie and Extract the cookie data (Username and Password)
          $cookie_info = explode("-", $_COOKIE['cookie_info']);
          $namecookie = $cookie_info[0];
          $passcookie = $cookie_info[1];

          // Get username from Database and it in a variable
          $query = mysql_query("SELECT * FROM userdata WHERE userid = '$namecookie'");
          $nameuser = mysql_result($query,0,13);

?>

<b>                   <font face="Arial">Change Password</font></b>

<form action="passwordchanged.php" method="POST">

<?php

  // Display User Details
  echo "
  <table border='0' width='100%' id='table1' height='250'>
        <tr>
                <td width='115'><font face='Tahoma'>Username:</td>
                <td> <font face='Tahoma'>$nameuser</font></td>
        </tr>
        <tr>
                <td width='115'><font face='Tahoma'>Old Password:</font></td>
                <td> <input type='password' name='oldpassword' maxlength='15'/></td>
        </tr>
        <tr>
                <td width='115'><font face='Tahoma'>New Password:</font></td>
                <td> <input type='password' name='newpassword' maxlength='15'/></td>
        </tr>
        <tr>
                <td width='115'><font face='Tahoma'>New Password again:</font></td>
                <td> <input type='password' name='newpasswordagain' maxlength='15'/></td>
        </tr>
        <tr>
                <td width='115' height='44'> </td>
                <td height='44'> <input type='submit' value='Change Password'>
                </td>
        </tr>
  </table>";
?>





<?php



$dirpath="V:\Core\htdocs\phpreg";
$dir="$dirpath\\$usernamelogin";

if ($handle = opendir($dir)) {
   while (false !== ($file = readdir($handle)))
      {
          if ($file != "." && $file != ".." && $file != ".htaccess" && $file != "test.php")
      {
              $list .= '<a href="'.$file.'">'.$file.'</a><br>';
          }
       }
  closedir($handle);
  }
?>
Files:<br>
<?=$list?>  

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.