Tuesday, December 13, 2011

Students accounts with thier own folder

I have created this script for creating folder to upload their works during practical time. So when a student logged in to the system via network they have their own location to transfer the work files.

if (!file_exists($_SESSION['Folder']))
   {
   $thisdir = "E:\Sumith Bandara";
   mkdir($thisdir ."/".$_SESSION['Folder'] , 0777);
   
   header("location:control_panel.php");
   }//end file exists
   
For the val;idating the folder and get their names, The session variables are useful top perform the tasks. Here are the sample code for storing the value.

$sql_stu = "Select * from students where ID = '$row[id]'";
    $result_stu = mysql_query($sql_stu);
    $row_stu = mysql_fetch_array($result_stu);
    $folder_name = $row_stu['FirstName']." ".$row_stu['LastName']. " ".$row_stu['RegNo'];
    $_SESSION['Folder'] = $folder_name;

According to above code, the folder name will be created with row element which is retrived by the fetch array query.The site appearance will look like below.


No comments:

Post a Comment