-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage_show.php
130 lines (105 loc) · 4.61 KB
/
Message_show.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
128
129
130
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<?php ob_start();
session_start();
if(!isset($_SESSION['myusername']))
header("location:index.html");
$userid=$_SESSION['ID'];
$ID=substr($userid,0,1);
?>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Messages</title>
<link href="CSS/bootstrap.css" rel="stylesheet">
<link href="CSS/bootstrap-responsive.css" rel="stylesheet">
<link href="CSS/Menubar.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="CSS/butt.css">
<link rel="stylesheet" type="text/css" href="CSS/fbstyle.css">
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(195, 223, 239);" alink="#000099" link="#000099" vlink="#990099">
<ul>
<li><a class="nonactive"<?php if($ID=='A') echo 'href="AdminPage.php"'; else if($ID=='T') echo 'href="StaffPage.php"';else echo 'href="StudentPage.php"'; ?>>Home</a></li>
<li><a <?php if($ID=='A') echo 'href="AdminNotification.php"'; else echo 'href="Notification.php"'; ?>><?php require 'notificationstyle.php'; ?></a></li>
<li><a href="Message.php"><?php require 'messagestyle.php'; ?></a></li>
<ul style="float: right; list-style-type: none;">
<li><a class="nonactive" href="rules.html">Rules of library</a></li>
<li><a <?php if($ID=='A') echo 'href="Adminlogin.php"'; else if($ID=='T') echo 'href="Stafflogin.php"';else echo 'href="Studentlogin.php"';?>>Logout</a></li>
</ul>
</ul>
<br>
<table style="width: 95%; height: 100%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="10" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;"> <img style="border: 1px solid ; width: 204px; height: 204px; float: left;" alt="User pic" src="userpics/<?php echo $_SESSION['ID']; ?>.jpg" hspace="10" vspace="15"> <br>
<br>
<br>
User Name: <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['myusername'].'</span>'; ?><br>
ID: <?php echo '<span style="font-family: Tahoma; color: red;">'.$_SESSION['ID'].'</span>'; ?><br>
</td>
<td style="width: 90%; vertical-align: top; background-color: grey;">
<?php
if(isset($_GET['sub1']))
{
$from=$_GET['msgid'];
$subject=$_GET['msgsb'];
echo '<div class="control-group" style="background-color: pink;">
<label class="control-label">
<center>Messages of:
<big style="color: red;"><span style="font-family: Tahoma;">
'.$from.'</span></big><br><br>
Subject:
<big style="color: red;"><span style="font-family: Tahoma;">
'.$subject.'
</span></big></center><br>
</label>
</div>';
require 'DBconnect.php';
if($ID=='A')
$sql="SELECT frm,message FROM messages WHERE frm='$from' and subject='$subject' and status_admin=1 order by sno desc";
else
$sql="SELECT frm,message FROM messages WHERE too='$userid' and subject='$subject' and status_user=1 order by sno desc";
$result=mysqli_query($con,$sql);
if(! $result )
die('Could not get data: ' . mysqli_error($con));
else
$count=mysqli_num_rows($result);
if($count>0)
{
echo '<div class="control-group" style="background-color: skyblue;">';
while($det = mysqli_fetch_assoc($result))
if($det['frm']==$userid)
echo '<label class="control-label"> Me: '.$det['message'].'<br></label>';
else
echo '<label class="control-label">'.$det['frm'].': '.$det['message'].'<br></label>';
}
if($ID=='A')
$sql="SELECT frm,message FROM messages WHERE ( frm='$from' or too='$from' ) and subject='$subject' and status_admin=0 order by sno desc";
else
$sql="SELECT frm,message FROM messages WHERE (too='$userid' or frm='$userid') and subject='$subject' and status_user=0 order by sno desc";
$result=mysqli_query($con,$sql);
if(! $result )
die('Could not get data: ' . mysqli_error($con));
else
$count=mysqli_num_rows($result);
if($count>0)
{
echo '<div class="control-group" style="background-color: white;">';
while($det = mysqli_fetch_assoc($result))
if($det['frm']==$userid)
echo '<label class="control-label"> Me: '.$det['message'].'<br></label>';
else
echo '<label class="control-label">'.$det['frm'].': '.$det['message'].'<br></label>';
}
if($ID=='A')
$sql=" UPDATE messages SET status_admin=0 WHERE frm='$from' and subject='$subject' and status_admin=1 order by sno desc";
else
$sql="UPDATE messages SET status_user=0 WHERE too='$userid' and subject='$subject' and status_user=1 order by sno desc";
$result=mysqli_query($con,$sql);
if(! $result )
die('Could not get data: ' . mysqli_error($con));
}
?>
</td>
</tr>
</tbody>
</table>
<?php ob_end_flush();?>
</body></html>