-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
81 lines (60 loc) · 1.73 KB
/
index.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
<?php
session_start();
require_once("controller.php");
?>
<html>
<head></head>
<body>
<?php
if (isset($_SESSION['added']) and isset($_SESSION['name']))
{
echo '<font color="red"><b>'.$_SESSION['name'].'</b>, your message has been successfully added. Be happy!</font>';
unset($_SESSION['add']);
unset($_SESSION['name']);
}
elseif (isset($_SESSION['edit']) and isset($_SESSION['name']))
{
echo '<font color="red"><b>'.$_SESSION['name'].'</b>, your message has been successfully edited. Be happy!</font>';
unset($_SESSION['edit']);
unset($_SESSION['name']);
}
elseif (isset($_SESSION['delete']) and isset($_SESSION['name']))
{
echo '<font color="red"><b>'.$_SESSION['name'].'</b>, your message has been successfully deleted. Be happy!</font>';
unset($_SESSION['delete']);
unset($_SESSION['name']);
}
?>
<form action="edit.php" method="post">
<input type="submit" name="add" value="Add message" />
</form>
<h2>Messages</h2><hr>
<?php
if (isset($mess) && empty($_SESSION['show']))
{
foreach($mess as $id => $mess)
{
echo '
<b>'.$mess['name'].'</b> is under <b>'.$mess['subject'].'</b><br>
<a href="index.php?id='.$mess['id'].'">Read</a><hr>';
}
}
elseif(isset($_SESSION['show'])) {
$mess = $base->getById($_GET['id']);
echo '<form action="edit.php" method="post">
<b>'.$mess['name'].'</b> is under <b>'.$mess['subject'].'</b><br>
<p>'.nl2br($mess['message']).'</p>
<input type="hidden" name="id" value="'.$mess['id'].'">
<input type="submit" name="edit" value="I changed my mind">
<input type="submit" name="delete" value="Delete"><br>
<a href="index.php">Back to the primitive</a>
<hr></form>';
unset($_SESSION['show']);
unset($_SESSION['id']);
}
else {
echo '<b>No messages. You can be first!</b><br>';
}
?>
</body>
</html>