-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.php
More file actions
142 lines (101 loc) · 5.09 KB
/
chat.php
File metadata and controls
142 lines (101 loc) · 5.09 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
session_start();
include 'database.php';
include 'common.php';
$touser ='';
if(isset($_GET['to'])){
$touser = mysqli_fetch_assoc(mysqli_query($con,"SELECT * FROM user WHERE id = '{$_GET['to']}'"));
$messages = mysqli_query($con,"SELECT * FROM messages WHERE (sent = '{$_SESSION['logUserId']}' AND receive = '{$touser['id']}') OR (receive = '{$_SESSION['logUserId']}' AND sent = '{$touser['id']}') ORDER BY id ASC");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Friends</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<div style='' class='navigation nav' >
<a class='' href='index.php'>Home</a>
<?php if(!isset($_SESSION['friendslogin'])){ ?> <a href='registration.php'>Registration</a> <?php } ?>
<a class='' href='members.php'>Members</a>
<?php if(isset($_SESSION['friendslogin'])){ ?>
<a class='' href='feed.php'>Feed</a>
<a class='' href='friends.php'>Friend List</a>
<a class='selected' href='chat.php'>Messages</a>
<a href='profile.php'>Profile</a>
<a class='' href='?logout=true'>Logout</a> <?php } ?>
</div>
<div class="container" style="border:solid 2px #3345;margin-top: 60px;padding: 20px;">
<div class="row">
<div class="col-lg-12">
<h4>Conversation</h4>
<p><?php if(isset($_SESSION['alert'])){echo $_SESSION['alert'];$_SESSION['alert']=''; } ?></p>
<center>
<div class="col-lg-6" style="border:solid 2px #5575;border-radius:10px">
<h4><?php if(isset($_GET['to'])){ echo $touser['fullname']; }else{ echo 'New Message';}?></h4>
</div>
</center>
</div>
<div class="col-lg-4" style="border:solid 2px #4445;margin-top: 30px;max-height: 350px;overflow-y: scroll;padding: 20px;">
<h3>Friend List</h3>
<div class="col-lg-12">
<?php
include 'get-friend-message-buttons.php';
?>
</div>
</div>
<div class="col-lg-8" style="border:solid 2px #4445;margin-top: 30px;max-height: 350px;overflow-y: scroll;padding: 20px;">
<table style="width:100%">
<?php
if(isset($_GET['to'])){
while($message = mysqli_fetch_assoc($messages)){
if($message['sent']==$_SESSION['logUserId']){
?>
<tr>
<td width="50%" style="text-align: right;"></td>
<td width="50%" style="text-align: right;">
<p class="alert alert-primary" style="float: right;"><?php echo $message['message']; ?></p><br>
</td>
</tr>
<?php
}else{
?>
<tr>
<td width="50%" style="text-align: left;">
<p class="alert alert-danger" style="width: auto!important;float: left;"><?php echo $message['message']; ?></p><br>
</td>
<td width="50%" style="text-align: left;"></td>
</tr>
<?php
}
}
}else{
}
?>
</table>
<?php if(isset($_GET['to'])){ ?>
<form method="post" action="send-message.php">
<div class="form-group">
<input class="form-control" placeholder="New Message" type="text" name="message" required id="sent" >
<input class="form-control" placeholder="New Message" type="hidden" name="sent" value="<?php echo $_SESSION['logUserId']; ?>" >
<input class="form-control" placeholder="New Message" type="hidden" name="receive" value="<?php echo $touser['id']; ?>" >
<button name="update-basics" style="float: right;" id="sent" value="<?php echo $me['id']; ?>" class="btn btn-primary">Send</button>
</div>
</form>
<?php } ?>
</div>
<div>
</div>
</div>
</div>
<div class="footer col-lg-12" style="margin-top: 100px;text-align: left;bottom: 0;width: 100%;">
<div class="col-lg-12">
</div>
<div class="col-lg-12">
</div>
</div>
</body>
</html>