-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
105 lines (95 loc) · 4.07 KB
/
index.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();
require_once 'database.php';
$query = "SELECT * FROM messages ORDER BY id DESC";
$shouts = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Web Chat</title>
<link rel="stylesheet" href="css/style.css" type="text/css"/>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
</head>
<body>
<!-- Navigation Bar-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Chat</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Web Chat</a></li>
<li><a href="#">Second Link</a></li>
<li><a href="#">Third Link</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">
<span
class="glyphicon glyphicon-user"></span> Logged in: <?php echo $_SESSION["user"]; ?>
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#"><span
class="glyphicon glyphicon-log-out"></span> Logout</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<h1 class="panel-title">Chaty</h1>
</div>
<div class="panel-body">
<ul class="list-group">
<?php while ($row = mysqli_fetch_assoc($shouts)) : ?>
<li class="list-group-item"><span><?php echo $row['time'] ?>
- </span><strong><?php echo $row['user'] ?>:</strong> <?php echo $row['message'] ?> </li>
<?php endwhile; ?>
</ul>
<div id="input">
<?php if (isset($_GET['error'])) : ?>
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<?php echo $_GET['error']; ?>
</div>
<?php endif; ?>
<form method="post" action="process.php">
<div class="input-group">
<label for="focusedInput">Name:</label>
<input class="form-control" id="focusedInput" type="text" name="user"
placeholder="Enter Your Name" value="<?php echo $_SESSION["user"]; ?>"/>
</div>
<div class="input-group">
<label for="focusedInput">Message:</label>
<input class="form-control input-lg" id="focusedInput" type="text" name="message"
placeholder="Enter A Message"/>
</div>
<br>
<div class="input-group">
<input class="btn-success " type="submit" name="submit" value="Send message"/>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
>
</body>
</html>