-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
78 lines (64 loc) · 2.26 KB
/
index.php
File metadata and controls
78 lines (64 loc) · 2.26 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>ChatApp</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body style="background:aqua;">
<div class="container " >
<div class="row " >
<div class="well " style="width: 640px;">
<div class="panel panel-default " style="width: 600px;">
<div class="panel-heading" align="center" style="background: lightblue;" >
<?php
include("connect.php");
session_start();
if(isset($_SESSION['username']))
{
echo 'Hello, '.$_SESSION['username'];
}
else
{
header("location:login.php");
}
?>
<button type="button" style="float: right; padding:0 9px" class="btn btn-info"><a href="logout.php" style="text-decoration: none; " >Logout</a></button>
</div>
</div>
<div id="message_area " >
<?php
$q1="select *from message";
$r1=mysqli_query($con,$q1);
while ($row=mysqli_fetch_assoc($r1)) {
$message=$row['message'];
$username=$row['username'];
echo '<h4 style="color:red;">'.$username.'</h4>';
echo '<p>'.$message.'</p>';
echo '<hr>';
}
if (isset($_POST['submit'])) {
$message=$_POST['message'];
$q=" INSERT INTO message (id,message,username) values('','$message', '{$_SESSION['username']} ' )";
if(mysqli_query($con,$q)){
echo '<h4 style="color:red">'.$_SESSION['username'].'<h4>';
echo '<p>'.$message.'</p>';
}
}
?>
</div><br>
<form method="post">
<div class="botto" style="width:600px;height: 40px;">
<input type="text" class="form-control" style="width: 545px;height: 35px; display: inline;" name="message" placeholder="type here">
<button style="width: 49px; display: inline;height: 40px; background:lightgreen; " class="btn btn-default btnclass="form-control-circle" type="submit" value="Message" name="submit"><i class="fa fa-paper-plane fa-2x" aria-hidden="true"></i>
</button>
</div></form>
</div>
</div>
</div>
</body>
</html>