-
Notifications
You must be signed in to change notification settings - Fork 0
/
inbox.php
106 lines (80 loc) · 2.53 KB
/
inbox.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
<?php ob_start(); ?>
<!DOCTYPE HTML>
<html>
<head>
<title>HalaudreyPets</title>
<link rel="stylesheet" href="items.css" type="text/css" />
</head>
<body>
<div class="main">
<button><a href="neopets.php" class="right"> Home </a></button>
<button><a href="inventory.php" class="right"> Inventory </a> </button>
<button><a href="marketplace.php" class="right"> Marketplace </a> </button>
<button><a href="cardGame.php" class="right"> Play Game </a></button>
<hr>
<button><a href="mailOptions.php?arg=send&id=">Compose Mail</a></button>
<h1 class="center"> Inbox </h1>
<?php
session_start();
$user= $_SESSION['username'];
if($user != "not_registered"){
require 'database.php';
?>
<table id="inbox">
<tr>
<th> From </th>
<th> Time Sent </th>
<th> Message </th>
<th> Options </th>
</tr>
<?php
$stmt = $mysqli->prepare("SELECT id, sender, time_sent, message FROM mail WHERE recipient=?");
$stmt->bind_param('s', $user);
$stmt->execute();
// Bind the results
$stmt->bind_result($id, $sender, $time_sent, $message);
while($stmt->fetch()){
echo "<tr>\n";
printf("<td>%s</td>\n <td>%s</td>\n <td>%s</td>\n",
htmlspecialchars($sender),
htmlspecialchars($time_sent), //convention: image_url will be item_name.jpg
htmlspecialchars($message)
);
printf("<td><button><a href=\"mailOptions.php?arg=delete&id=%d\">Delete</a></button></td>\n", $id);
}
echo "</tr>\n";
$stmt->close();
?>
</table>
<hr>
<h1 class="center"> Sent Mail </h1>
<table id="inbox">
<tr>
<th> To </th>
<th> Time sent </th>
<th> Message </th>
</tr>
<?php
$stmt = $mysqli->prepare("SELECT id, recipient, time_sent, message FROM mail WHERE sender=?");
$stmt->bind_param('s', $user);
$stmt->execute();
// Bind the results
$stmt->bind_result($id, $recipient, $time_sent, $message);
while($stmt->fetch()){
echo "<tr>\n";
printf("<td>%s</td>\n <td>%s</td>\n <td>%s</td>\n",
htmlspecialchars($recipient),
htmlspecialchars($time_sent), //convention: image_url will be item_name.jpg
htmlspecialchars($message)
);
}
echo "</tr>\n";
$stmt->close();
?>
</table>
</div>
<?php
}
?>
</body>
</html>