-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroom.php
More file actions
175 lines (148 loc) · 5.4 KB
/
room.php
File metadata and controls
175 lines (148 loc) · 5.4 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
session_start();
$roomname = $_GET['roomname'];
$_SESSION['roomname'] = $roomname;
// echo $roomname;
include('dbcon.php');
//existence of room
$sql = "SELECT * FROM rooms where roomname = '$roomname'";
$result = $conn->query($sql);
// $rr = $result->fetch_assoc();
// var_dump($rr);
if ($result->num_rows == 0) {
echo "<script>alert('room does not exist')</script>";
// echo "<script>location.href='index.php';</script>";
} else {
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap/css/talewind.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="fontawesome\css\all.css">
<style>
body {
margin: 0 auto;
max-width: 800px;
padding: 0 20px;
}
.container {
border: 2px solid #dedede;
background-color: #f1f1f1;
border-radius: 5px;
padding: 10px;
margin: 10px 0;
}
.darker {
border-color: #ccc;
background-color: #ddd;
}
.container::after {
content: "";
clear: both;
display: table;
}
.container img {
float: left;
max-width: 60px;
width: 100%;
margin-right: 20px;
border-radius: 50%;
}
.container img.right {
float: right;
margin-left: 20px;
margin-right: 0;
}
.time-right {
float: right;
color: #aaa;
}
.time-left {
float: left;
color: #999;
}
.anyclass {
height: 400px;
overflow-y: scroll;
}
</style>
<!-- <link rel="stylesheet" href="css/style1.css">
<link rel="stylesheet" href="css/style.css"> -->
<!-- <link rel="stylesheet" href="css/home.css"> -->
</head>
<body>
<h2>Chat Messages- <?php echo $roomname; ?></h2>
<!-- <div class="container"> -->
<div class="container">
<div class="anyclass">
<div class="row">
<div class="col-md-12">
<!-- <img src="/w3images/bandmember.jpg" alt="Avatar" style="width:100%;"> -->
<!-- <p>Hello. How are you today?</p>
<span class="time-right">11:00</span> -->
<?php
$sql12 = "SELECT * from msg where room = '$roomname'";
$result12 = $conn->query($sql12);
while ($row1 = $result12->fetch_assoc()) {
// var_dump($row1);
?>
<div class="container">
<p><?php echo $row1['msg']; ?></p>
<small><?php echo $row1['ip']; ?></small>
<span class="time-right"><?php echo $row1['stime']; ?></span>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="container">
<form method="POST">
<input type="text" name="usermsg" id="usermsg" class="form-control mb-2" placeholder="Add message">
<button class="btn btn-info" style="float: right;" name="submitmsg" id="submitmsg">send</button>
</form>
</div>
</div>
<script src="bootstrap/js/jquery-3.2.1.slim.min.js"></script>
<script src="bootstrap/js/jquery.vide.js"></script>
<script src="bootstrap/js/popper.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script type="text/javascript">
$("#submitmsg").click(function(e) {
// e.preventDefault();
var clientmsg = $("#usermsg").val();
$.post("postmsg.php", {
text: clientmsg,
room: '<?php echo $roomname; ?>',
ip: '<?php echo $_SERVER['REMOTE_ADDR'] ?>'
},
function(data, status) {
document.getElementsByClassName('anyclass')[0].innerHTML = data;
}
);
// return false;
});
</script>
</body>
</html>
<?php
}
// if (isset($_REQUEST['submitmsg'])) {
// if ($_REQUEST['usermsg'] == "") {
// echo "aadd";
// } else {
// $msg = $_REQUEST['usermsg'];
// // $room = $roomname;
// $ip = $_SERVER['REMOTE_ADDR'];
// $sql = "INSERT INTO `msg` ( `msg`, `room`, `ip`, `stime`) VALUES ( '$msg ', '$roomname', '$ip', current_timestamp());";
// $result = $conn->query($sql);
// if ($result == false) {
// echo "<script> alert('tyytPOST'); </script>";
// }
// }
// }
?>