-
Notifications
You must be signed in to change notification settings - Fork 1
/
message.php
99 lines (73 loc) · 2.39 KB
/
message.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
<?php
require_once './management/main.php';
if (isset($_POST['friend']) || isset($_SESSION['friend'])) {
if (isset($_POST['friend'])) {
$friend = $_POST['friend'];
} else {
$friend = $_SESSION['friend'];
}
$user = $_SESSION['user'];
unsetMessages($connection, $friend);
$allMessages = $user->getMessage($connection, $friend);
$from = Message::findName($connection, $user->getEmail());
$to = Message::findName($connection, $friend);
} else {
header("Location: $profilePageV2");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./styles/messages.min.css">
</head>
<body>
<form class="back" action="./profile.php">
<button class="profile">
<?php include './components/svg/profile.php'?>
</button>
</form>
<form class='wrapper' action="" method="POST">
<span class="toUser"><?php echo $to ?></span>
<span class="fromUser"><?php echo $from ?></span>
<div class="messages">
<?php foreach ($allMessages as $messsage): ?>
<?php if ($friend == $messsage->getMessageFrom()): ?>
<div class="from">
<h1>
<?php echo $messsage->getMessageDate() ?>
</h1>
<?php echo $messsage->getMessage() ?>
</div>
<?php endif?>
<?php if ($friend == $messsage->getMessageTo()): ?>
<div class="to">
<h1>
<?php echo $messsage->getMessageDate() ?>
</h1>
<?php echo $messsage->getMessage() ?>
</div>
<?php endif?>
<?php endforeach?>
</div>
<div class="messageWrapper">
<textarea name="content" placeholder="send a message">
</textarea>
<input style="display:none" type="text" name='friend'>
<button class='send' type="submit" name="send" value='<?php echo $friend ?>'>
<?php include "./components/svg/send.php"?>
</button>
</div>
</form>
</body>
<script>
function gotoBottom(){
var element = document.querySelector('.messages');
element.scrollTop = element.scrollHeight;
}
gotoBottom();
</script>
</html>