-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
executable file
·118 lines (110 loc) · 3.14 KB
/
search.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
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
require_once 'core/init.php';
$user = new User();
if(!$user->isLoggedIn()) {
Redirect::to('index.php');
}
if(Input::exists('get')) {
$fields = array(
'username' => Input::get('username'),
'firstName' => Input::get('firstName'),
'middleName' => Input::get('middleName'),
'lastName' => Input::get('lastName')
);
$search = new Search();
$input = false;
foreach($fields as $field => $value) {
if(!empty($value)) {
$input = true;
}
}
if($input) {
if($search->search($fields)) {
$results = $search->results();
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'includes/header.php'; ?>
<div id="main-wrapper" class="wrapper">
<div id="sidebar" class="left">
<ul>
<li><a href="./">Recent Activity</a></li>
<li><a href="friend-requests.php">Friend Requests</a></li>
<li><a href="my-friends.php">Friends</a></li>
<li class="selected-option"><a href="search.php">Search</a></li>
</ul>
</div>
<div id="main-container" class="page friends">
<h2 class="title">Search</h2>
<?php include 'includes/alerts.php'; ?>
<div id="search">
<form action="search.php" method="get">
<table>
<tr>
<td>
<label for="username">Username</label>
</td>
<td>
<label for="firstName">First Name</label>
</td>
<td>
<label for="middleName">Middle Name</label>
</td>
<td>
<label for="lastName">Last Name</label>
</td>
</tr>
<tr>
<td>
<input id="username" type="text" name="username" autocomplete="off">
</td>
<td>
<input id="firstName" type="text" name="firstName" autocomplete="off">
</td>
<td>
<input id="middleName" type="text" name="middleName" autocomplete="off">
</td>
<td>
<input id="lastName" type="text" name="lastName" autocomplete="off">
</td>
</tr>
<tr>
<td>
<input type="submit" name="search" value="Search">
</td>
<td>
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</td>
</tr>
</table>
</form>
</div>
<h3 class="subtitle"></h3>
<div id="friends">
<div id="all-friends">
<?php if(!empty($results)) : ?>
<?php foreach($results as $result) : $resultName = $result->firstName . ' ' . $result->middleName . ' ' . $result->lastName; ?>
<div class="friend">
<div class="friend-picture">
<a href="profile.php?user=<?php echo $result->username; ?>"><img src="<?php echo $result->profilePicture; ?>"></a>
</div>
<span class="name"><a href="profile.php?user=<?php echo $result->username; ?>"><?php echo $resultName; ?></a></span>
</div>
<?php endforeach; ?>
<?php else : ?>
<p>No results.</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
</body>
</html>