-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatpage.php
105 lines (98 loc) · 1.75 KB
/
chatpage.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
100
101
102
103
104
105
<?php
session_start();
if(isset($_SESSION['name']))
{
include "layouts/header2.php";
include "config.php";
$sql="SELECT * FROM `chat`";
$query = mysqli_query($conn,$sql);
?>
<style>
h2{
color:white;
}
label{
color:white;
}
span{
color:#FFFF00 ;
font-weight:bold;
}
.container {
margin-top: 3%;
width: 60%;
background-color: #26262b9e;
padding-right:10%;
padding-left:10%;
}
.btn-primary {
background-color: #673AB7 ;
}
.display-chat{
background-image: url("images/bg.jpg");
height:300px;
background-color:#d69de0;
margin-bottom:4%;
overflow:auto;
padding:15px;
}
.message{
background-color: #c616e469;
color: white;
border-radius: 5px;
padding: 5px;
margin-bottom: 3%;
}
</style>
<div class="container">
<center><h2>Welcome <span style="color:#dd7ff3;"><?php echo $_SESSION['name']; ?> !</span></h2>
<label>Join the chat</label>
</center></br>
<div class="display-chat">
<?php
if(mysqli_num_rows($query)>0)
{
while($row= mysqli_fetch_assoc($query))
{
?>
<div class="message">
<p>
<span><?php echo $row['name']; ?> :</span>
<?php echo $row['message']; ?>
</p>
</div>
<?php
}
}
else
{
?>
<div class="message">
<p>
No previous chat available.
</p>
</div>
<?php
}
?>
</div>
<form class="form-horizontal" method="post" action="sendMessage.php">
<div class="form-group">
<div class="col-sm-10">
<textarea name="msg" class="form-control" placeholder="Type your message here..."></textarea>
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-primary">Send</button>
</div>
</div>
</form>
</div>
</body>
</html>
<?php
}
else
{
header('location:index.php');
}
?>