-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
51 lines (43 loc) · 1.23 KB
/
search.php
File metadata and controls
51 lines (43 loc) · 1.23 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
<?php
include 'init.php';
include 'func/search.func.php';
// check to make sure only logged in users can create albums
if (!logged_in()){
header('Location: index.php');
exit;
}
include 'template/header.php';
?>
<section id="main_section">
<article class="transparent">
<h2>Search</h2>
<form action="" method="post">
<p>
<input type="text" name="keywords"/> <input type="submit" value="Search"/>
</p>
</form>
</article>
<?php
if(isset($_POST['keywords'])){
$keywords = mysql_real_escape_string(htmlentities(trim($_POST['keywords'])));
$errors = array();
if(empty($keywords)){
$errors[] = 'Please enter a search term';
} else if(strlen($keywords) < 3){
$errors[] = 'Your search term must be 3 or more characters long';
} else if (1==2) {
$errors[] = 'Your search for '.$keywords.'returned no results';
}
if (empty ($errors)){
search_results($keywords);
} else {
foreach ($errors as $error){
echo $error, '</br>';
}
}
}
?>
</section>
<?php
include 'template/footer.php';
?>