Echo problem when another user logs in.

I am trying to change the output of my system list or table when another user logs in.


I have 2 primary users (admin and super admin) and minor users (registered with the company). using my administrator is downloading files sent by another company. the downloaded file is then transferred to another super admin account. super administrator is used to approve or reject uploaded files sent by the administrator. These files were originally obtained from another company. The table is already sorted by employee’s name, status and name. and I already inserted the condition that it must repeat the name and identifier once.

This condition is before

when the administrator logs in, the table in the house will display all downloaded files, regardless of their status. This also applies to the super admin. while in another company only files uploaded by an employee in that company can be viewed or displayed. all this code is working correctly.

This is the condition that I expect now

when the administrator logs in, the table in the home table will display all downloaded files, regardless of their status. when the super administrator logs in, only files with an approved status and are not approved on the home page will be displayed. the downloaded file with the pending status should be an echo on another page, which I called "New Downloads", which I am currently working on. And when other users log in, they will only see files with an approved or unapproved status.

I hope somehow I made it clear. :( I tried to solve this problem within 2 days, but the wrong outputs always appear, so I would like to ask you to help :(


this is what the output table looks like on my system

  if the admin page is login

 * EmployeeID * * EmployeeName * * Title * * FileDate * * Status * * Confirmation *

   20864125 Keisha file2 Feb 01, 2000 Pending Delete
   20080407 Mariel file5 Aug 01, 2000 Pending Delete
                                      file1 Jan 01, 2000 Pending Delete
   16521253 Riorei file13 Jan 01, 2000 Pending Delete
                                      file10 Mar 20, 2003 Pending Delete  

 if the super admin login

 * EmployeeID * * EmployeeName * * Title * * FileDate * * Status * * Confirmation *

   20864125 Keisha file2 Feb 01, 2000 Pending Approve / Not Approve
   20080407 Mariel file5 Aug 01, 2000 Pending Approve / Not Approve
                                      file1 Jan 01, 2000 Pending Approve / Not Approve
   16521253 Riorei file13 Jan 01, 2000 Pending Approve / Not Approve
                                      file10 Mar 20, 2003 Pending Approve / Not Approve     

 an if other user log in

 * EmployeeID * * EmployeeName * * Title * * FileDate * * Status *           

   20864125 Keisha file2 Feb 01, 2000 Pending         

now that you see the difference, I would like to apply a new condition in this release: (this is the code I used


while ($row = mysql_fetch_assoc($query)) { $file_id = $row['file_id']; $file_desc = $row['file_description']; $file_date = $row['file_date']; $file_name = $row['file_name']; $file_accs = $row['folder_access']; $file_employee = $row['employee_id']; $file_confir = $row['confirmation']; $file_ename = ucwords($row['employee_name']); $emp_id=$emp_id==$row['employee_id']?"":$row['employee_id']; $emp_name=$emp_name==$row['employee_name']?"":$row['employee_name']; $info = pathinfo($file_name); $file_ext = $info['extension']; echo '<tr> <td> &nbsp; </td> </tr> <tr class="subone"> <td class="sub" width="100"> '.$emp_id.' <br /> &nbsp; </td>'; if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa') { ?><td class="sub" width="100"> <a href="" onclick = javascript:newPopup('addfile.php?emp=<?php echo $file_employee ?>');><?php echo$emp_name?></a> <br /> &nbsp; </td><?php } else { echo '<td class="sub" width="182"> '.$emp_name.' <br /> &nbsp; </td>'; } echo'<td class="sub" width="218"> <a href="'.$file_accs.$file_name.'" target="_blank" style="text-decoration: underline;">'.$file_desc.'</a> <br /> &nbsp; </td> <td class="sub" width="100"> '.date('M d, Y',mktime(0,0,0,substr($file_date,5,2),substr($file_date,8,2),substr($file_date,0,4))).' <br /> &nbsp; </td> <td class="sub" width="100"> '.$file_confir.' <br /> &nbsp; </td>'; if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa') { if($file_confir == 'Pending' OR $file_confir == 'NotApproved') { if(isset($_GET['id'])) { $fgmembersite->Delete_Db($_GET['id']); } echo '<td class="sub" width="100"> <a href="index.php?id='.$file_id.'">Delete</a> <br /> &nbsp; </td>'; } } else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') { if($file_confir == 'Pending') { if(isset($_GET['yes'])) { $fgmembersite->UpdateYesDB($_GET['yes']); //echo "<script>location.reload();</script>"; } else if(isset($_GET['no'])) { $fgmembersite->UpdateNoDB($_GET['no']); //echo "<script>location.reload();</script>"; } if (!isset($_GET['offset'])) { $prevoffset = 0; } else { $prevoffset = $_GET['offset']; } echo'<td class="sub" width="100"> <a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'&namelist='.$listname.'&yes='.$file_id.'">Approve</a> <br /><br /> <a href="index.php?offset='.$prevoffset.'&searchfile='.$search.'&namelist='.$listname.'&no='.$file_id.'">NotApprove</a> &nbsp; </td> '; } } }?> 

this works correctly when a new condition is not yet applied. Now my problem is how can I apply the new condition here? I tried using this code set:

 if($_SESSION[$fgmembersite->GetLoginSessionVar()] != 'sa' && $file_confir == '' OR $file_confir == 'NotApproved') 

before echoing. but this led to the wrong result, can someone tell me what to do here? :( I know that I have to use the conditions for this, but I do not know which one is suitable. thanks to those who will answer.

0
source share
1 answer

Your if / elseif statement checks for admin and superadmin already, will the regular user just be in another?

 if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa'){ // your code here } elseif($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin') { // more code here } else { // here goes the code of your regular user if($file_confir == '' OR $file_confir == 'NotApproved'){ // display the file } } 

As a side note: it might be easier for you to write code / debug version if you don't mix HTML and PHP. The formatting / indentation of the code is also not consistent, but this may be due to copy / paste

0
source

All Articles