-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.php
77 lines (49 loc) · 1.57 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
<?php
error_reporting (E_ALL ^ E_NOTICE);
$conn = new mysqli('localhost', 'root', '', 'daycaredb');
session_start();
$username=$_SESSION['username'];
error_reporting(0);
if(isset($_POST["submit"]))
{
$to=$_POST['to'];
$message=$_POST['message'];
$from=$_SESSION['username'];
$sql ="INSERT INTO `messages` (`message_to`, `message_from`, `message`) VALUES ('$to','$from','$message')";
$result=$conn->query($sql);
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<link rel="stylesheet" href="message.css">
<body>
<div class="msgbox">
<div class="container">
<center><p>Messages</p></center>
</div>
<?php
error_reporting (E_ALL ^ E_NOTICE);
$conn = new mysqli('localhost', 'root', '', 'daycaredb');
session_start();
$username=$_SESSION['username'];
$sql="SELECT * FROM messages WHERE message_to='$username'";
$result=$conn->query($sql);
while($row = mysqli_fetch_assoc($result)){
echo "<tr><td>" . $row['message_from']."<br>" . "</td><td>" . $row['message']."<br>". "</td><td>" .$row['time']. "</td></tr>"."<br><br>" ;
}
?>
</div>
<div class="sendmsg">
<form action="message.php" method="post">
<p>Send To</p>
<input type="text" name="to" placeholder="Enter recipient username" required="">
<p>Message</p>
<input type="text" name="message" placeholder="Type message" required="">
<input type="submit" name="submit" value="Send">
</form>
</div>
</body>
</html>