-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwelcome.php
79 lines (77 loc) · 2.65 KB
/
welcome.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
<?php
include('session.php');
if (isset($_POST['search'])) {
$searchInput = $_POST['search'];
$query = "SELECT city, address, phone FROM offices WHERE city LIKE '$searchInput'";
} else {
$query = "SELECT city, address, phone FROM offices";
}
$result = $db->query($query);
if (!$result) {
$error = $db->error;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Netlight Security Challenge</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php if (isset($error)) {
echo '<div class="alert alert-danger alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'.$error.'</div>';
} ?>
<div class="container">
<h1>Welcome</h1>
<a href="logout.php"><button type="button" class="btn btn-primary">Log Out</button></a>
<h3>Search Office</h3>
<form method="post" action="" class="form-search">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="input-group">
<input type="text" class="form-control" name="search" id="searchInput" placeholder="City" autofocus>
<span class="input-group-btn">
<input type="submit" name="submit" value="Search" class="btn btn-primary">
</span>
</div>
</div>
</div>
</form>
<div class="well col-xs-12 col-sm-6">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>City</th>
<th>Address</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<?php if ($result && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["city"]."</td><td>".$row["address"]."</td><td>".$row["phone"]."</td></tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>