-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload_mails.php
127 lines (107 loc) · 4.47 KB
/
load_mails.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="profile.css">
</head>
<body>
<table class="table">
<?php
session_start();
include "SQL_connection.php";
$idmail="";
$mail="";
$username="";
$subject="";
$counter=1;
$usr=$_SESSION['user'];
$query = "SELECT * FROM mailbox";
$result = mysqli_query($link,$query);
$num = mysqli_num_rows($result);
//check if is admin
$queryadmin = "SELECT isadmin FROM accounts WHERE Username = '$usr' ";
$resultadmin = mysqli_query($link,$queryadmin);
$rowadmin = mysqli_fetch_array($resultadmin);
if($rowadmin['isadmin'] == 1){
$printsadmins = 1;
}else{
$printsadmins = 0;
}
if($printsadmins){
if ($num>0) {
echo '<thead>
<tr>
<th style = "font-size:16px;" scope="col">No.</th>
<th style = "font-size:16px;" scope="col">Email</th>
<th style = "font-size:16px;" scope="col">Subject</th>
<th style = "font-size:16px;" scope="col">Message</th>
</tr>
</thead>
<tbody>' ;
while($row = mysqli_fetch_array($result)){
$idmail=$row['idmailbox'];
$message=$row['MainMessage'];
$email=$row['Email'];
$subject=$row['MesSubject'];
echo '<tr>
<td> <label style = "font-size:14px;">'; echo $counter; echo '</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $email ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $subject ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $message ; echo'</label></td>
</tr>';
$counter = $counter + 1 ;
}
echo '</tbody>' ;
}
else{
echo 'There are no emails yet !';
}
}else{
$query1 = "SELECT Email FROM accounts WHERE Username='$usr'";
$result1 = mysqli_query($link,$query1);
$row1 = mysqli_fetch_array($result1);
$temp = 1 ;
$i = 0;
while($row = mysqli_fetch_array($result)){
$i = $i + 1;
$idmail=$row['idmailbox'];
$message=$row['MainMessage'];
$email=$row['Email'];
$subject=$row['MesSubject'];
if($row1['Email']==$email && $temp==1){
echo '<thead>
<tr>
<th style = "font-size:16px;" scope="col">No.</th>
<th style = "font-size:16px;" scope="col">Email</th>
<th style = "font-size:16px;" scope="col">Subject</th>
<th style = "font-size:16px;" scope="col">Message</th>
</tr>
</thead>
<tbody>' ;
echo '<tr>
<td> <label style = "font-size:14px;">'; echo $counter; echo '</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $email ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $subject ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $message ; echo'</label></td>
</tr>';
$counter = $counter + 1 ;
$temp = 2;
}else if ($row1['Email']==$email){
echo '<tr>
<td> <label style = "font-size:14px;">'; echo $counter; echo '</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $email ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $subject ; echo'</label></td>';
echo '<td> <label style = "font-size:14px;">'; echo $message ; echo'</label></td>
</tr>';
$counter = $counter + 1 ;
}
if($num == $i && $temp == 1){
echo 'You have not sent any emails yet !';
}
}
echo '</tbody>' ;
}
mysqli_close($link);
?>
</table>
</body>
</html>