-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwelcome.php
58 lines (56 loc) · 2.38 KB
/
welcome.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
<?php
session_start();
if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin']!==true){
header("location: login.php");
exit;
}
require("mysql_conn.php");
$username=$_SESSION['username'];
?>
<html>
<head>
<title>Muse@ - Welcome</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
</head>
<body>
<div class="header_wrap">
<div class="header_div">
<div class='menu_item act_menu first_menu_item'><a href='welcome.php'>Home</a>
</div><div class="menu_item"><a href="muse.php">Send Closed</a>
</div><div class="menu_item"><a href="open_logged_in.php">Send Open</a>
</div><div class="menu_item"><a href="settings.php">+</a>
</div><div class='menu_item last_menu_item float_right'><a href='logout.php'>Logout @<?php echo $username;?></a>
</div></div></div>
<div class="content_div"><div class="welcome"><h2>Welcome @<?php echo $username;?> ,</h2></div>
<?php
$result=$conn->query("select distinct sender from $username where inbox is not null union select distinct receiver from $username where outbox is not null;");
if($result->num_rows==0){
echo "<div class='welcome'><p>no messages.</p></div>";
}else{
// display id's with new messages on top
while($sender=$result->fetch_assoc()){
$rows=$conn->query("select inbox from $username where sender='".$sender['sender']."' and viewed='0' and inbox is not null order by id desc;");
$new_inbox=$rows->num_rows;
if($new_inbox>0){
echo "<a href='view_inbox.php?id=".$sender['sender']."'><div class='museid_row'>@".$sender['sender']." (".$new_inbox." new message/s)</div></a>";
}else{
//echo "<a href='view_inbox.php?id=".$sender['sender']."'><div class='museid_row'>@".$sender['sender']."</div></a>";
}
}
// display remaining id's
$result->data_seek(0);
while($sender=$result->fetch_assoc()){
$rows=$conn->query("select inbox from $username where sender='".$sender['sender']."' and viewed='0' and inbox is not null order by id desc;");
$new_inbox=$rows->num_rows;
if($new_inbox>0){
//echo "<a href='view_inbox.php?id=".$sender['sender']."'><div class='museid_row'>@".$sender['sender']." (".$new_inbox." new message/s)</div></a>";
}else{
echo "<a href='view_inbox.php?id=".$sender['sender']."'><div class='museid_row'>@".$sender['sender']."</div></a>";
}
}
}
?>
</div>
</body>
</html>