-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmessages.php
54 lines (50 loc) · 1.2 KB
/
messages.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
<?php
require_once 'header.php';
$user = $_SESSION['user'];
$error = $msg = $msgreciever = "";
if(isset($_POST['msgreciever']))
{
$msgreciever = $_POST['msgreciever'];
$msg = $_POST['msg'];
$msg = cleanup($msg);
if($msgreciever == "" || $msg == "")
{
$error = "You forgot the message or its reciever.";
}
else
{
$checkuser = runthis("SELECT * FROM members WHERE user='$msgreciever'");
if($checkuser->num_rows != 0)
{
runthis("INSERT INTO messages VALUES('$user', '$msgreciever', '$msg', 'date()')");
$error = "Message sent.";
}
else
{
$error = "reciever does not exist.";
}
}
}
?>
<!-- <form method='post' action='messages.php'>
To: <input type='text' name='msgreciever'><br>
Message: <input type='text' name='msg'><br>
<input type='submit' value='Send'>
</form>
<br>
-->
<div class='wrapper'>
<div class='chatnames'></div>
<div class='chatcontainer'></div>
</div>
<?php
// $result = runthis("SELECT * FROM messages WHERE reciever='$user' OR sender='$user'");
// $n = $result->num_rows;
// for($j = 0; $j < $n; $j = $j + 1)
// {
// $row = $result->fetch_array(MYSQLI_ASSOC);
// echo "<div class='msg'>" . $row['sender'] . ": " . $row['content'] . "<br><br></div>";
// }
?>
</body>
</html>