-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshoutbox.php
60 lines (57 loc) · 2 KB
/
shoutbox.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
<!DOCTYPE html>
<html>
<head>
<?php
include("database.php");
//create select query
try {
$shouts = $db->query("SELECT * FROM shouts ORDER BY id DESC");
} catch (Exception $e) {
echo "Data could not be retrieved from the database.";
exit;
}
$pageTitle = "Shout Box";
include("inc/head.php");
?>
</head>
<body>
<?php include("inc/header.php"); ?>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading text-center"><h1>SHOUT IT OUT!</h1></div>
<div class="panel-body">
<ul>
<!-- fetch in shouts from database -->
<?php foreach($shouts->fetchAll(PDO::FETCH_ASSOC) as $row){ ?>
<li><span><?php echo $row['time']; ?> - </span><?php echo "<b>".$row['user'].":</b>"; ?> <?php echo $row["message"]; ?></li>
<?php } ?>
</ul>
</div>
<div id="input">
<?php if(isset($_GET["error"])): ?>
<div class="error">
<?php echo $_GET["error"]; ?>
</div>
<?php endif;?>
<!-- forms for user's name, message and submit button -->
<div class="panel-footer">
<form method="POST" action="process.php">
<div class="col-md-3 form-group">
<label class="control-label">Name (maximum of 20 characters): </label>
<input class="form-control" type="text" name="user" maxlength="20" placeholder="Enter Your Name" />
</div>
<div class="col-md-9 form-group">
<label class="control-label">Message (maximum of 100 characters): </label>
<input class="form-control" type="text" name="message" maxlength= "100" placeholder="Enter A Message"/>
</div>
<br/>
<div class="form-group">
<input class="btn btn-success btn-block" type="Submit" name="submit" value="Shout It Out"/>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>